Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Attempt at using old netcdf reading code in model versions beyond 1.0.4 not working

I am trying to port my code modifications from cesm1.0.4 to cesm1.2.2 on pleiades-san. In this mod I used commands from the file .../models/atm/cam/src/control/wrap_nf.F90. It used to work, but now crashes during compiling when I try to read in 3 dimensional variable. I noticed at the top of the wrap_nf.F90 file that there is the following message:
!-------------------------------------------------------------------------------
!
! WARNING: USE OF THIS MODULE WITHIN CAM IS DEPRECATED. ALL
! HANDLING OF NETCDF FILES SHOULD ULTIMATELY BE DONE
! BY PIO, OR FOR PORTABLE CODE, SHOULD CONTACT THE
! NETCDF F90 INTERFACE DIRECTLY.
!
! DO NOT USE THIS MODULE.
!
!-------------------------------------------------------------------------------


As such, I think I should update my code to not use this module. What is the best way to read in netcdf variables without using this module. I assume this is done somewhere else in the model, so if someone could direct me to where that occurs, I can use it as an example. Thank you for your assistance.

For the record the error I am getting right now is:
/u/epeck/case/sdwaccm_codrescu_1_2_2/SourceMods/src.cam/mo_epp.F90(154): error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [EPP_MEPED_ALPHA]
call wrap_get_var_realx(fid, alpha_vid, epp_meped_alpha)
------------------------------------------------^

Relevant lines of code that lead up to this error are:
use wrap_nf, only: wrap_inq_varid, wrap_get_var_int, wrap_get_var_realx, wrap_close, wrap_open, wrap_inq_dimid, wrap_inq_dimlen
...
...
real(r8), allocatable, dimension(:,:,:) :: epp_meped_alpha
...
...
allocate(epp_meped_alpha(epp_meped_nLevs, epp_meped_nLats, epp_meped_nMLTs))
...
...
call wrap_inq_varid(fid, 'energy', alpha_vid)
call wrap_get_var_realx(fid, alpha_vid, epp_meped_alpha)

I should note that I use these same commands for some 1dim vectors, and the compiler gives me no issues.

Any advice I can get to deal with this would be great! Thank you!

-Ethan
 

eaton

CSEG and Liaisons
The easiest path forward is to use the F90 NetCDF interfaces directly.  The wrap_nf interfaces are only providing a thin layer which deals with checking the return codes.  There is a subroutine called handle_ncerr in  src/control/error_messages.F90 that you can use for this purpose.
 

santos

Member
The wrap_nf module had an interface that was not quite correct according to the Fortran standard, and this caused some compatibility issues, which is why it was modified to only work for one-dimensional variables. Since it is also less flexible than the netCDF Fortran 90 interface, it was deprecated.The simplest thing for you to do is to use the netCDF interface directly. The functions are similar to the wrap_nf functions except that they return an error code. The documentation for the Fortran interface is here:http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90.htmlAlternatively, you can use PIO. PIO is a more efficient way to read files, but it may take more time to figure out. If you go this route, you should use cam_pio_openfile from cam_pio_utils to create the PIO file descriptor. PIO documentation is here:http://www.cesm.ucar.edu/models/pio/
 
Great, thanks for the advice Sean! I will try to learn the PIO route since I will likely need to do this many times in my future and should really just get comfortable with it. -Ethan
 
Top