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

Error: Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

dayon

Member
Error: Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Dear Scientists
Sorry to bother you. I want to read some data into the CESM2.1.3. Therefore, I edit a new F90 named "readin.F90" according to the structure of other .F90 files. At the same time, I add some menbers to the type of "waterflux_type" ib the WaterfluxType.F90.
In addition, I call the readin.F90 in the lnd_comp_mct.F90.
But when run the cesm, the ./case.build can success, but the ./case.submit always failed. Could you give me some suggestions?

the readin.F90 is as follows:
module readinMod

!---------------------------------------------------------------------------
!BOP
!
! !MODULE: readin
!
! Read three ET component at every time step
!
! !PUBLIC MEMBER FUNCTIONS:
implicit none

! !PUBLIC MEMBER FUNCTIONS:
!
public :: readin ! read in three ET components at pft/patch level
!
! !REVISION HISTORY:
! Author: Dayang Wang
! 2021-03-18
!

!EOP
!===============================================================
contains
!===============================================================

!---------------------------------------------------------------------------
!BOP
!
! !IROUTINE: readin
!
! !INTERFACE:
subroutine readin(yr, mon, day, sec, atm2lnd_inst)
!
! !DESCRIPTION:
! read in three ET components at pft/patch level
! !USES:
use shr_kind_mod , only : r8 => shr_kind_r8
use fileutils , only : getfil
use ncdio_pio
use abortutils , only : endrun
use clm_time_manager , only : get_nstep, get_step_size
use atm2lndType , only : atm2lnd_type
use clm_varctl , only : iulog
use spmdMod , only : masterproc, spmd_init, mpicom, MPI_CHARACTER
use decompMod , only : get_proc_bounds, get_proc_global
use clm_varcon , only : grlnd
use WaterfluxType ! Dayon.W suspect
use netcdf
implicit none
!
! !ARGUMENTS:
integer, intent(in) :: yr ! year (19xx, ...)
integer, intent(in) :: mon ! month (1, ..., 12)
integer, intent(in) :: day ! day of month (1, ..., 31)
integer, intent(in) :: sec ! seconds of the day (00000, ..., )
type(atm2lnd_type), intent(in) :: atm2lnd_inst
! type(waterflux_type),intent(in) :: waterflux_inst ! Dayon.W suspect

!
! !LOCAL VARIABLES:
integer :: hour ! hours of the day (1, ... , 24)
character(len=256) :: indir ! directory
character(len=10) :: cdate ! date string, e.g., 2000-01-01
character(len=256) :: filenam ! file name
character(len=256) :: dirfilenam ! concatenate of dir and filename
character(len=256) :: locfn ! local file
character(len=256) :: fetdat ! et_ratio file name
type(file_desc_t) :: ncid ! netcdf id
type(waterflux_type):: waterflux_inst ! Dayon.W suspect
integer :: idqvege ! variable id
integer :: idqvegt ! variable id
integer :: idqsoil ! variable id
integer :: status ! file status
integer :: ipft ! pft index
integer :: igridcell ! gridcell index

integer :: numg ! total number of gridcells across all processors
integer :: numl ! total number of landunits across all processors
integer :: numc ! total number of columns across all processors
integer :: nump ! total number of pfts across all processors
integer :: ier ! error code

logical :: readvar ! determine if variable is on initial file

!
! !REVISION HISTORY:
! Author: Dayang Wang
!
! EOP
!-----------------------------------------------------------------------

! Dagang add begin
hour = sec/3600 + 1
!if (masterproc) then
! write(iulog,*) 'yr = ', yr
! write(iulog,*) 'mon = ', mon
! write(iulog,*) 'day = ', day
! write(iulog,*) 'hour = ', hour
!end if

! et_ratio
! fetdat = '/scratch/daw02012/cesminput/readin/NLDAS-0250-ET_ratio_025D_GLEAM.nc' Dagang dirfile
fetdat = '/home/dayon/Downloads/CLM_GLEAM/ET_ratio/V3.5a/Global_ETthree_ratio_GLEAM_yr_1986_1999_mo_01_12.nc'
call getfil(trim(fetdat), locfn, 0)
call mpi_bcast (locfn, len(locfn) , MPI_CHARACTER, 0, mpicom, ier)
call ncd_pio_openfile (ncid, trim(locfn), 0)
call check_dim(ncid, 'time', 12)
call ncd_io(ncid=ncid, varname='QVEGE_ratio', flag='read', &
data=atm2lnd_inst%qvege_ratio, dim1name=grlnd,nt=mon)
call ncd_io(ncid=ncid, varname='QVEGT_ratio', flag='read', &
data=atm2lnd_inst%qvegt_ratio, dim1name=grlnd,nt=mon)
call ncd_io(ncid=ncid, varname='QSOIL_ratio', flag='read', &
data=atm2lnd_inst%qsoil_ratio, dim1name=grlnd,nt=mon)
call ncd_pio_closefile(ncid)

!if (mon==1 .OR. mon==2 .OR. mon==3 .OR. mon==12) then
! clm_a2l%qvege_ratio(:) = 1.0_r8
! clm_a2l%qvegt_ratio(:) = 1.0_r8
! clm_a2l%qsoil_ratio(:) = 1.0_r8
!end if

call get_proc_global(numg, numl, numc, nump)

! indir = '/scratch/daw02012/cesmoutput/NLDAS_ctl_0250/run' Dagang dir
indir = '/home/dayon/cesm/archive/CLM50SpGs_res1D_CTRL/lnd/hist'
write(cdate,'(i4.4,"-",i2.2,"-",i2.2)') yr,mon,day
!if (masterproc) write(iulog,*) 'cdate = ', cdate

! filenam = 'NLDAS_ctl_0250.clm2.h1.'//cdate//'-00000.nc' Dagang file
filenam = 'CLM50SpGs_res1D_CTRL.clm2.h1.'//cdate//'-00000.nc'
dirfilenam = trim(indir) //'/'//trim(filenam)
call getfil(dirfilenam, locfn, 0)
call mpi_bcast (locfn, len(locfn) , MPI_CHARACTER, 0, mpicom, ier)
call ncd_pio_openfile(ncid, dirfilenam, 0)

call check_dim(ncid, 'gridcell', numg)
call check_dim(ncid, 'landunit', numl)
call check_dim(ncid, 'column' , numc)
call check_dim(ncid, 'pft' , nump)

call ncd_io(ncid=ncid, varname='QVEGE', flag='read', dim1name='pft', &
data=waterflux_inst%qflx_evap_can_patch_readin, nt=hour)
call ncd_io(ncid=ncid, varname='QVEGT', flag='read', dim1name='pft', &
data=waterflux_inst%qflx_tran_veg_patch_readin, nt=hour)
call ncd_io(ncid=ncid, varname='QSOIL', flag='read', dim1name='pft', &
data=waterflux_inst%qflx_evap_soi_patch_readin, nt=hour)

end subroutine readin

end module readinMod
 

dayon

Member
I thought the error is result from the
call ncd_io(ncid=ncid, varname='QSOIL', flag='read', dim1name='pft', &
data=waterflux_inst%qflx_evap_soi_patch_readin, nt=hour)


Thus, I modified the it to dim1name=namep, and add the "namep" to the "use clm_varcon , only : grlnd,namep".
However, this modification Don't work, and the same errors still exist.

It make me puzzled, anyone can give me some suggestions? Thanks in advance.
 
Top