0
votes

I only came across netcdf lately and have not much clue about using it. Besides-the problem I have is specific and I haven't yet found anything useful. I have a fortran code that performs claculations in parralel, using MPI. The end results-3d fields in cartesian coordinate sistem-are then written each to another file using netcdf. The writing process is defined by the following code:

nf90_create(path=file_name,&
           cmode=IOR(NF90_NETCDF4,NF90_MPIIO),ncid=ncid,&
           comm=mpid%comm,info=MPI_INFO_NULL))

now, I have another code that uses netcdf3 so it cannot read netcdf4 format. What I want to do is to change in cmode NF90_NETCDF4 with NF90_CLASSIC_MODEL. When I do this, the code compiles, runs, but it writes the data in completely wrong manner. Also, it stops before it goes from writing variable A onto writing variable B. Or before it has to exit the subroutine in which this command is used. To clarify a bit more: after the presented command, the code defines start and count according to the MPI and uses the followind netcdf commands:

nf90_def_dim(ncid,dim_name(i),dim_len(i),dimid(i))
nf90_def_var(ncid,var_name,nf90_real,dimid,varid(1))
nf90_enddef(ncid)
nf90_put_var(ncid,varid(1),var,start=startv,count=countv)
nf90_close(ncid)

So, I'm interested, what should I change for the code to write the desired data in classic or 64bit_offstring format without mentioned issues. If the presentation of the problem is unclear, I can provide the original subroutine that gives me trouble.

thank you for all the comments in advance

1
from the CMakeList of the code I see that the netcdf4 is used. To be more specific, here is the whole list of used libraries, connected with netcdf:-I/opt/netcdf/netcdf4/include -L/opt/netcdf/netcdf4/lib -lnetcdff -L/opt/pnetcdf/pnetcdf-1.2.0/lib -L/opt/netcdf/netcdf4/hdf5.1.8.8/lib -lnetcdf -lpnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl;user3316906

1 Answers

2
votes

Did you check the status given back by the NetCDF routines? Writing into the NetCDF3 format in parallel is not possible anyway, so probably there should already be an error in your nf90_open statement. Try to encapsulate your NetCDF calls into the check subroutine provided. This should give you more meaningful error messages:

call check( nf90_open(...) )


contains
  subroutine check(status)
    integer, intent ( in) :: status

    if(status /= nf90_noerr) then 
      print *, trim(nf90_strerror(status))
      stop "Stopped"
    end if
  end subroutine check