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

which .f90 file is to read netcdf file

liyongkang

liyongkang
New Member
I am a new for CLM and CESM. Now I want to read a new netcdf file(.nc) to memery to involve in CLM compute. So I want to know which .f90 file is to do it. Thanks!
It seems that the ncdio_pio.f90 file is to write the .nc file, but I want to read .nc file.
 

oleson

Keith Oleson
CSEG and Liaisons
Staff member
There are several examples of reading netcdf files in the CLM5 code. Look at UrbanParamsType.F90 for example.
There are a couple of "use ncdio_pio" statements that make available several ncdio_pio functions:

use ncdio_pio , only : file_desc_t, ncd_io, ncd_inqvdlen, ncd_inqfdims
use ncdio_pio , only : ncd_pio_openfile, ncd_pio_closefile, ncd_inqdid, ncd_inqdlen.

The file is opened using:

call ncd_pio_openfile (ncid, locfn, 0)

Variables are read in from the file using the "flag='read'", e.g.,

call ncd_io(ncid=ncid, varname='CANYON_HWR', flag='read', data=urbinp%canyon_hwr,&
dim1name=grlnd, readvar=readvar)

Then the file is closed using:

call ncd_pio_closefile(ncid)
 

liyongkang

liyongkang
New Member
There are several examples of reading netcdf files in the CLM5 code. Look at UrbanParamsType.F90 for example.
There are a couple of "use ncdio_pio" statements that make available several ncdio_pio functions:

use ncdio_pio , only : file_desc_t, ncd_io, ncd_inqvdlen, ncd_inqfdims
use ncdio_pio , only : ncd_pio_openfile, ncd_pio_closefile, ncd_inqdid, ncd_inqdlen.

The file is opened using:

call ncd_pio_openfile (ncid, locfn, 0)

Variables are read in from the file using the "flag='read'", e.g.,

call ncd_io(ncid=ncid, varname='CANYON_HWR', flag='read', data=urbinp%canyon_hwr,&
dim1name=grlnd, readvar=readvar)

Then the file is closed using:

call ncd_pio_closefile(ncid)
Thanks a lot! Now I achieve the goal by " use necdf ",but It's running a little slow. Then I would try the way that You suggested. Thanks agin, I a new about the cesm.
 
Top