Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code optimization & reorganize files. #325

Merged
merged 8 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/Makeoptions
Empty file modified include/Makeoptions.CMA-HPC
100644 → 100755
Empty file.
39 changes: 39 additions & 0 deletions include/Makeoptions.SYSU-BaiduBoat.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ==========================================================
# mpif90 - gnu

# please "source /share/home/dq089/soft/gnu-env" first.

FF = mpif90

NETCDF_LIB = /share/home/dq089/soft/netcdf-fortran-4.6.1-gnu/lib
NETCDF_INC = /share/home/dq089/soft/netcdf-fortran-4.6.1-gnu/include

MOD_CMD = -J

FOPTS = -fdefault-real-8 -ffree-form -C -g -u -xcheck=stkovf \
-ffpe-trap=invalid,zero,overflow -fbounds-check \
-mcmodel=medium -fbacktrace -fdump-core -cpp \
-ffree-line-length-0

INCLUDE_DIR = -I../include -I../share -I../mksrfdata -I../mkinidata -I../main -I$(NETCDF_INC)
LDFLAGS = -L${NETCDF_LIB} -lnetcdff -llapack -L/share/home/dq089/soft/lib -lblas.gnu

#============================================================
# CaMa-Flood Mkinclude (for Linux, gfortran)

RM = /bin/rm -f
CP = /bin/cp
#----
# Pre-Prosessing options
# DMPI=-DUseMPI: activate when MPI parallelization is used
# DCDF=-DUseCDF: activate when using netCDF, comment out when not needed
# DATM=-DNoAtom: activate when OMP ATOMIC calculation should be avoided (bit identical simulation)
#----
#DMPI=-DUseMPI
DCDF=-DUseCDF
#DATM=-DNoAtom
CFLAGS=$(DMPI) $(DCDF) $(DATM)
#----
FCMP = gfortran -fopenmp
FC = gfortran
FFLAGS = -O3 -Wall -cpp -free -fimplicit-none -fbounds-check -fbacktrace
46 changes: 46 additions & 0 deletions include/Makeoptions.SYSU-BaiduBoat.intel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# =======================================================
# mpif90 - intel

# please "source /share/home/dq089/soft/intel-env" first.

FF = mpif90

NETCDF_LIB = /share/home/dq089/soft/netcdf-fortran-4.6.1-intel/lib
NETCDF_INC = /share/home/dq089/soft/netcdf-fortran-4.6.1-intel/include

MOD_CMD = -module

#<<<<<<< HEAD
#FOPTS = -qopenmp -g -traceback -r8 -free -check uninit
# -r8 -free -O0 -check uninit -check bounds -check pointers \
# -traceback -assume byterecl -pthread -heap-arrays #-nogen-interface

#INCLUDE_DIR = -I../include -I../share -I../mksrfdata \
# -I../mkinidata -I../main -I../hydro -I${NETCDF_INC}
#LDFLAGS = -L${NETCDF_LIB} -lnetcdff


FOPTS = -qopenmp -O2 -traceback -r8 -free -check uninit -check bounds

LDFLAGS = -L${NETCDF_LIB} -lnetcdff -llapack -L/share/home/dq089/soft/lib -lgfortran -lblas.intel

#============================================================
# CaMa-Flood Mkinclude (for Linux, gfortran)

RM = /bin/rm -f
CP = /bin/cp
#----
# Pre-Prosessing options
# DMPI=-DUseMPI: activate when MPI parallelization is used
# DCDF=-DUseCDF: activate when using netCDF, comment out when not needed
# DATM=-DNoAtom: activate when OMP ATOMIC calculation should be avoided (bit identical simulation)
#----
#DMPI=-DUseMPI
DCDF=-DUseCDF
#DATM=-DNoAtom
CFLAGS=$(DMPI) $(DCDF) $(DATM)
#----
FCMP = ifort -qopenmp
FC = ifort
LFLAGS =
FFLAGS = -O3 -warn all -fpp -free -assume byterecl -heap-arrays -nogen-interface -lpthread -static-intel
Empty file modified include/Makeoptions.SYSU-BaiduBoat_Parallel_with_zip
100644 → 100755
Empty file.
52 changes: 52 additions & 0 deletions include/Makeoptions.github
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# =======================================================
# mpif90 - gfortran
#

FF = mpif90 -fopenmp

NETCDF_LIB = /usr/lib/x86_64-linux-gnu
NETCDF_INC = /usr/include

MOD_CMD = -J

# determine the gfortran version
GCC_VERSION := "`gcc -dumpversion`"
IS_GCC_ABOVE_10 := $(shell expr "$(GCC_VERSION)" ">=" "10")
ifeq "$(IS_GCC_ABOVE_10)" "1"
FOPTS = -fdefault-real-8 -ffree-form -C -g -u -xcheck=stkovf \
-ffpe-trap=invalid,zero,overflow -fbounds-check \
-mcmodel=medium -fbacktrace -fdump-core -cpp \
-ffree-line-length-0 -fallow-argument-mismatch
else
FOPTS = -fdefault-real-8 -ffree-form -C -g -u -xcheck=stkovf \
-ffpe-trap=invalid,zero,overflow -fbounds-check \
-mcmodel=medium -fbacktrace -fdump-core -cpp \
-ffree-line-length-0
endif

INCLUDE_DIR = -I../include -I../share -I../mksrfdata -I../mkinidata -I../main -I$(NETCDF_INC)
LDFLAGS = -L$(NETCDF_LIB) -lnetcdff -lnetcdf -llapack -lblas



#============================================================
# CaMa-Flood Mkinclude (for Linux, gfortran)

RM = /bin/rm -f
CP = /bin/cp
#----
# Pre-Prosessing options
# DMPI=-DUseMPI: activate when MPI parallelization is used
# DCDF=-DUseCDF: activate when using netCDF, comment out when not needed
# DATM=-DNoAtom: activate when OMP ATOMIC calculation should be avoided (bit identical simulation)
#----
#DMPI=-DUseMPI
DCDF=-DUseCDF -DUseCDF_CMF
#DATM=-DNoAtom
CFLAGS=$(DMPI) $(DCDF) $(DATM)
#----
FCMP = /usr/bin/gfortran -fopenmp
FC = /usr/bin/gfortran

LFLAGS =
FFLAGS = -O3 -Wall -cpp -free -fimplicit-none -fbounds-check -fbacktrace
7 changes: 2 additions & 5 deletions include/Makeoptions.gnu → include/Makeoptions.land.gnu
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

FF = mpif90 -fopenmp

NETCDF_LIB = /usr/lib/x86_64-linux-gnu
NETCDF_INC = /usr/include

# NETCDF_LIB = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/lib
# NETCDF_INC = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/include
NETCDF_LIB = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/lib
NETCDF_INC = /opt/netcdf-c-4.9.2-fortran-4.6.0-gnu/include

MOD_CMD = -J

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion main/MOD_LAIReadin.F90
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ SUBROUTINE LAI_readin (year, time, dir_landdata)
#ifdef URBAN_MODEL
IF(m == URBAN) CYCLE
#endif
IF( m == 0 )THEN
IF(m == 0 .or. m == WATERBODY)THEN
fveg(npatch) = 0.
tlai(npatch) = 0.
tsai(npatch) = 0.
Expand Down
74 changes: 43 additions & 31 deletions mkinidata/MOD_IniTimeVariable.F90
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ SUBROUTINE IniTimeVar(ipatch, patchtype&
IF(patchtype <= 5)THEN ! land grid

! (1) SOIL temperature, water and SNOW
! Variables: t_soisno, wliq_soisno, wice_soisno
! snowdp, sag, scv, fsno, snl, z_soisno, dz_soisno
! Variables: t_soisno, wliq_soisno, wice_soisno, wa, zwt
IF (use_soilini) THEN
! (1.1) all temperature, water and zwt from data.

zi_soi_a(:) = (/0., zi_soi/)

Expand Down Expand Up @@ -408,9 +408,36 @@ SUBROUTINE IniTimeVar(ipatch, patchtype&
wa = wa + 5000.
ENDIF

ELSEIF (use_wtd) THEN
! (1.2) only zwt is from data.

DO j = 1, nl_soil
IF(patchtype==3)THEN !land ice
t_soisno(j) = 253.
wliq_soisno(j) = 0.
wice_soisno(j) = dz_soisno(j)*denice
ELSE
t_soisno(j) = 283.
wliq_soisno(j) = dz_soisno(j)*porsl(j)*denh2o
wice_soisno(j) = 0.
ENDIF
ENDDO

IF (patchtype <= 1) THEN
CALL get_water_equilibrium_state (zwtmm, nl_soil, wliq_soisno(1:nl_soil), smp, hk, wa, &
zc_soimm, zi_soimm, porsl, vliq_r, psi0, hksati, nprms, prms)
ELSE
wa = 0.
zwt = 0.
ENDIF

IF (.not. DEF_USE_VariablySaturatedFlow) THEN
wa = wa + 5000.
ENDIF

ELSE
! (1.3) cold start

! soil temperature, water content
DO j = 1, nl_soil
IF(patchtype==3)THEN !land ice
t_soisno(j) = 253.
Expand All @@ -423,8 +450,21 @@ SUBROUTINE IniTimeVar(ipatch, patchtype&
ENDIF
ENDDO

IF (DEF_USE_VariablySaturatedFlow) THEN
wa = 0.
zwt = zi_soimm(nl_soil)/1000.
ELSE
! water table depth (initially at 1.0 m below the model bottom; wa when zwt
! is below the model bottom zi(nl_soil)
wa = 4800. !assuming aquifer capacity is 5000 mm
zwt = (25. + z_soisno(nl_soil))+dz_soisno(nl_soil)/2. - wa/1000./0.2 !to result in zwt = zi(nl_soil) + 1.0 m
ENDIF

ENDIF


! (2) snow initialization
! variables: snowdp, sag, scv, fsno, snl, z_soisno, dz_soisno
z0m = htop * z0mr
#if (defined LULC_IGBP_PFT || defined LULC_IGBP_PC)
IF(patchtype==0)THEN
Expand Down Expand Up @@ -500,34 +540,6 @@ SUBROUTINE IniTimeVar(ipatch, patchtype&

ENDIF

! (2) SOIL aquifer and water table
! Variables: wa, zwt
IF (.not. use_wtd) THEN

IF (.not. use_soilini) THEN
IF (DEF_USE_VariablySaturatedFlow) THEN
wa = 0.
zwt = zi_soimm(nl_soil)/1000.
ELSE
! water table depth (initially at 1.0 m below the model bottom; wa when zwt
! is below the model bottom zi(nl_soil)
wa = 4800. !assuming aquifer capacity is 5000 mm
zwt = (25. + z_soisno(nl_soil))+dz_soisno(nl_soil)/2. - wa/1000./0.2 !to result in zwt = zi(nl_soil) + 1.0 m
ENDIF
ENDIF
ELSE
IF (patchtype <= 1) THEN
CALL get_water_equilibrium_state (zwtmm, nl_soil, wliq_soisno(1:nl_soil), smp, hk, wa, &
zc_soimm, zi_soimm, porsl, vliq_r, psi0, hksati, nprms, prms)
ELSE
wa = 0.
zwt = 0.
ENDIF

IF (.not. DEF_USE_VariablySaturatedFlow) THEN
wa = wa + 5000.
ENDIF
ENDIF

! (3) soil matrix potential hydraulic conductivity
! Variables: smp, hk
Expand Down
10 changes: 6 additions & 4 deletions mksrfdata/Aggregation_PercentagesPFT.F90
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ SUBROUTINE Aggregation_PercentagesPFT (gland, dir_rawdata, dir_model_landdata, l
-1.0e36_r8, lndname, 'pct_crop_patch', compress = 1, write_mode = 'one')
#endif
#else
allocate (SITE_croptyp(numpatch))
allocate (SITE_pctcrop(numpatch))
SITE_croptyp = cropclass
SITE_pctcrop = pctshrpch
IF (.not. USE_SITE_pctcrop) THEN
allocate (SITE_croptyp(numpatch))
allocate (SITE_pctcrop(numpatch))
SITE_croptyp = cropclass
SITE_pctcrop = pctshrpch
ENDIF
#endif
#endif

Expand Down
2 changes: 2 additions & 0 deletions mksrfdata/MOD_LandCrop.F90
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ SUBROUTINE landcrop_build (lc_year)

CALL pixelsetshared_build (landpatch, gcrop, cropdata, N_CFT, cropfilter, &
pctshrpch, cropclass, fracin = pctshared)

cropclass = cropclass + N_PFT - 1

numpatch = landpatch%nset

Expand Down
4 changes: 2 additions & 2 deletions mksrfdata/MOD_LandPFT.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ SUBROUTINE landpft_build (lc_year)
#ifdef CROP
ELSEIF (landpatch%settyp(1) == CROPLAND) THEN
DO ipft = 1, numpft
landpft%settyp(ipft) = cropclass(ipft) + N_PFT - 1
landpft%settyp(ipft) = cropclass(ipft)
pft2patch (ipft) = ipft
patch_pft_s (ipft) = ipft
patch_pft_e (ipft) = ipft
Expand Down Expand Up @@ -273,7 +273,7 @@ SUBROUTINE landpft_build (lc_year)
landpft%eindex(npft) = landpatch%eindex(ipatch)
landpft%ipxstt(npft) = landpatch%ipxstt(ipatch)
landpft%ipxend(npft) = landpatch%ipxend(ipatch)
landpft%settyp(npft) = cropclass(ipatch) + N_PFT - 1
landpft%settyp(npft) = cropclass(ipatch)

landpft%pctshared(npft) = landpatch%pctshared(ipatch)

Expand Down
2 changes: 1 addition & 1 deletion mksrfdata/MOD_SingleSrfdata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MODULE MOD_SingleSrfdata
#endif

#ifdef CROP
real(r8), allocatable :: SITE_croptyp (:)
integer, allocatable :: SITE_croptyp (:)
real(r8), allocatable :: SITE_pctcrop (:)
#endif

Expand Down
71 changes: 0 additions & 71 deletions run/CRA40_Grid_50km_IGBP_VG.nml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading