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

Input .nc file into CLM

Status
Not open for further replies.
Hi--
I’m trying to put a .nc file into CLM for it to read and calculate physics in the dust module DUSTMod.F90. I changed namelist_definition.xml and user_nl_clm for reading the namelist_variable.
For namelist_definition_clm4_0.xml:
<!-- soil diameter -dmleung, 22 Apr 2020 -->
<entry id="soil_diam" type="char*256" input_pathname="abs" category="datasets"
group="clm_inparm" valid_values="" >
Full pathname of time-invariant soil diameter dataset for calculating dust saltation threshold.
</entry>

For user_nl_clm:
&clm_inparm
soil_diam='/glade/u/home/dleung/CESM/edit_namelist/soil_diameter-19x25-04222020.nc'
/

I guess I’m doing right above? I am then less certain about how to use PIO library to read the .nc file in DUSTMod.F90 like this (after doing use ncdio_pio, and defining all the needed parameters):
!-----------------------------------------------------------------------
! read in soil diameter dataset (and interpolate to CLM native grid?)
! by dmleung, 29 Apr 2020
call getfil(soil_diam, soil_diam_file, 0)
call ncd_pio_openfile (ncid, trim(soil_diam_file), PIO_NOWRITE)
! Get input data resolution.
ierr = pio_inq_dimid( ncid, 'lon', did )
ierr = pio_inq_dimlen( ncid, did, nlon )
ierr = pio_inq_dimid( ncid, 'lat', did )
ierr = pio_inq_dimlen( ncid, did, nlat )
allocate(dst_lons(nlon))
allocate(dst_lats(nlat))
allocate(soil_diameter_in(nlon,nlat))
ierr = pio_inq_varid( ncid, 'lon', vid )
ierr = pio_get_var( ncid, vid, dst_lons )
ierr = pio_inq_varid( ncid, 'lat', vid )
ierr = pio_get_var( ncid, vid, dst_lats )
ierr = pio_inq_varid( ncid, 'mbl_bsn_fct_geo', vid )
ierr = pio_get_var( ncid, vid, soil_diameter_in )
Am I doing right above? Moreover, I wonder if my dataset is a 2D (long by lat) static map, do I need to regrid the data to CLM native grid? I saw that CAM has interpolation functions like get_rlat_all_p, lininterp, etc. Are there any similar functions in CLM and what functions do I need to read and regrid the dataset?
I attached the detailed scripts, if needed. Any help is highly appreciated.
Many thanks,
Danny
 

Attachments

  • user_nl_clm.txt
    1.8 KB · Views: 2
  • DUSTMod_v1a.F90.txt
    51.6 KB · Views: 3
  • namelist_definition_clm4_0_v1.xml.txt
    34.4 KB · Views: 1
Also, when I try to compile the model it gives out the error message (as follows, log file is attached). Why would this error occur even after I specified the path variable in namelist_definition_clm4_0.xml?

/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(55): error #6562: A data initialization-expr is not valid for this object. [SOIL_DIAM]
character(cl) :: soil_diam = 'soil_diam' ! full pathname for soil diameter dataset
-----------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(735): error #6451: A dummy argument name is required in this context. [LBP]
integer, intent(in) :: lbp, ubp ! pft bounds, -dml 23 Apr 2020
---------------------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(735): error #6451: A dummy argument name is required in this context. [UBP]
integer, intent(in) :: lbp, ubp ! pft bounds, -dml 23 Apr 2020
--------------------------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(821): error #6451: A dummy argument name is required in this context. [SOIL_DIAM]
character(cl), intent(in) :: soil_diam
---------------------------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(55): error #6404: This name does not have a type, and must have an explicit type. [CL]
character(cl) :: soil_diam = 'soil_diam' ! full pathname for soil diameter dataset
----------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(55): error #6841: An automatic object must not appear in the specification part of a module. [SOIL_DIAM]
character(cl) :: soil_diam = 'soil_diam' ! full pathname for soil diameter dataset
-----------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(868): error #6404: This name does not have a type, and must have an explicit type. [SOIL_DIAMETER]
allocate(soil_diameter(nlon,nlat))
-------------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(877): error #6284: There is no matching specific function for this generic function reference. [PIO_GET_VAR]
ierr = pio_get_var( ncid, vid, soil_diameter )
-----------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(881): error #6404: This name does not have a type, and must have an explicit type. [P]
do p = lbp,ubp
-------^
/glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90(881): error #6063: An INTEGER or REAL data type is required in this context. [P]
do p = lbp,ubp
-------^
compilation aborted for /glade/scratch/dleung/CESM/diam_case0.3/SourceMods/src.clm/DUSTMod.F90 (code 1)
/glade/scratch/dleung/CESM/diam_case0.3/Tools/Makefile:643: recipe for target 'DUSTMod.o' failed
gmake: *** [DUSTMod.o] Error 1
gmake: *** Waiting for unfinished jobs....
 

Attachments

  • lnd.bldlog.200429-131503.txt
    116.1 KB · Views: 0

oleson

Keith Oleson
CSEG and Liaisons
Staff member
I think I would use the "streams" capability in CLM. The streams method can handle interpolation in space and time. For CLM4, you could follow the nitrogen deposition example, src_clm40/main/ndepStreamMod.F90.
 
Status
Not open for further replies.
Top