1

I'm trying to compile one particular numerical code named NEMO. I'm using PGI compiler and get the following error while I'm trying to run a case.

-> report : Performance report : Time spent for XIOS : 4.53964e-05
-> report : Performance report : Time spent in processing events : 0
-> report : Performance report : Ratio : 0%
-> report : Performance report : Time spent for XIOS : 4.54746e-05
-> report : Performance report : Time spent in processing events : 0
-> report : Performance report : Ratio : 0%
0: Null pointer for qrp (/home/user/local/NEMO-4.0/cfgs/MYGYRE/BLD/ppsrc/nemo/diawri.f90: 530)

0: Null pointer for qrp (/home/user/local/NEMO-4.0/cfgs/MYGYRE/BLD/ppsrc/nemo/diawri.f90: 530)

0: Null pointer for qrp (/home/user/local/NEMO-4.0/cfgs/MYGYRE/BLD/ppsrc/nemo/diawri.f90: 530)

0: Null pointer for qrp (/home/user/local/NEMO-4.0/cfgs/MYGYRE/BLD/ppsrc/nemo/diawri.f90: 530)

The corresponding code from the diawri.f90 file is as followed

530          CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping

Following is the interface of histwrite

  INTERFACE histwrite
!---------------------------------------------------------------------
!- The "histwrite" routines will give the data to the I/O system.
!- It will trigger the operations to be performed,
!- and the writting to the file if needed
!-
!- We test for the work to be done at this time here so that at a
!- later stage we can call different operation and write subroutine
!- for the REAL and INTEGER interfaces
!-
!- INPUT
!- idf      : The ID of the file on which this variable is to be,
!-            written. The variable should have been defined in
!-            this file before.
!- pvarname : The short name of the variable
!- pitau    : Current timestep
!- pdata    : The variable, I mean the real data !
!- nbindex  : The number of indexes provided. If it is equal to
!-            the size of the full field as provided in histdef
!-            then nothing is done.
!- nindex   : The indices used to expand the variable (pdata)
!-            onto the full field.

This is the qrp definition

   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qrp   !: heat flux damping        [w/m2]

I searched online and find some information saying this is due to a fortran 2003 standard about null pointer. And different compilers treat null pointer differently. As I know gfortran is mostly used for compiling this code and seemingly working fine. I would like to know what I can do to avoid the error without changing the compiler.

2
  • How is qrp defined? If it is ALLOCATABLE array, is it allocated? How is histwrite defined? Commented Oct 1, 2019 at 18:17
  • @jacob, I've added the interface definition of histwrite in the question and as well as the declare of qrp. It is an allocatable array and I think it is not allocated. Commented Oct 1, 2019 at 19:06

1 Answer 1

1

Looking at the code, the interface histwrite resolves to the following subroutine for your qrp:

SUBROUTINE histwrite_r2d (idf,pvarname,pitau,pdata,nbindex,nindex)
!---------------------------------------------------------------------
  IMPLICIT NONE
!-
  INTEGER,INTENT(IN) :: idf,pitau,nbindex
  INTEGER,DIMENSION(nbindex),INTENT(IN) :: nindex
  REAL,DIMENSION(:,:),INTENT(IN) :: pdata
  CHARACTER(LEN=*),INTENT(IN) :: pvarname
!---------------------------------------------------------------------
  CALL histw_rnd (idf,pvarname,pitau,nbindex,nindex,pdata_2d=pdata)
!---------------------------
END SUBROUTINE histwrite_r2d

The dummy argument pdata (to be associated with the actual qrp) is a assumed-shape array, but not allocatable. This means that the paragraph 7 of section 15.5.2.4 of the current Fortran standard applies:

  1. Except in references to intrinsic inquiry functions, if the dummy argument is nonoptional and the actual argument is allocatable, the corresponding actual argument shall be allocated.

In other words, passing a non-allocated qrp to histwrite is invalid in Fortran, because the compiler can't associate non-existing array with an existing one.

I believe that, internally, gfortran just passes on a null pointer, which then makes the optional argument pdata_2d in call to histw_rnd appear as not present. But I suspect that this is more of a coindidence than a design.

There's little you can do; this is a problem of the code. You would need to fix it yourself, perhaps by using directly histw_rnd (bypassing histwrite) without any of its optional arguments, or by allocating qrp. I don't think there is a magical compiler option for PGI that would just solve it for you.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot @jacob. I'm not expert, only started the installation of the software and want to make use of it. Do you think additional IF statement to pass a null pointer when qrp is not allocated is feasible?
@user3289737 I can imagine making the dummy argument pdata allocatable in all subroutines histwrite_r?d, and adding an IF into those subroutines to only pass that array into the dummy argument pdata_?d of histw_rnd when allocated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.