From 27e01396ea1ff2c99e294612ce56ed274d1f2c2e Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 5 Sep 2024 10:04:58 +0200 Subject: [PATCH 1/4] renamed mod_nuopc_methods.F90 to ocn_import_export.F90 to be consistent with rest of noresm components --- drivers/nuopc/{mod_nuopc_methods.F90 => ocn_import_export.F90} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename drivers/nuopc/{mod_nuopc_methods.F90 => ocn_import_export.F90} (100%) diff --git a/drivers/nuopc/mod_nuopc_methods.F90 b/drivers/nuopc/ocn_import_export.F90 similarity index 100% rename from drivers/nuopc/mod_nuopc_methods.F90 rename to drivers/nuopc/ocn_import_export.F90 From c41cb51727ebd850b3c47c067db478dcdf7a34fd Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 14 Sep 2024 20:43:19 +0200 Subject: [PATCH 2/4] added new dms exchange and made all open statements use newunit= syntax --- ben02/mod_ben02.F90 | 49 +++++----- channel/mod_channel.F90 | 85 ++++++++-------- cime_config/buildnml | 15 --- drivers/mct/ocn_comp_mct.F90 | 5 +- drivers/nocoupler/blom.F | 4 +- drivers/noforc/blom.F | 5 +- drivers/nuopc/ocn_comp_nuopc.F90 | 144 +++++++++++++++++++--------- drivers/nuopc/ocn_import_export.F90 | 18 ++-- hamocc/mo_hamocc_init.F90 | 2 +- phy/mod_budget.F90 | 25 ++--- phy/mod_dia.F90 | 8 +- phy/mod_diffusion.F90 | 6 +- phy/mod_geoenv.F90 | 7 +- phy/mod_idarlx.F90 | 7 +- phy/mod_rdlim.F90 | 16 ++-- phy/mod_restart.F90 | 12 ++- phy/mod_vcoord.F90 | 6 +- phy/mod_xc.F90 | 2 +- 18 files changed, 238 insertions(+), 178 deletions(-) diff --git a/ben02/mod_ben02.F90 b/ben02/mod_ben02.F90 index 040d5310..f7154cca 100644 --- a/ben02/mod_ben02.F90 +++ b/ben02/mod_ben02.F90 @@ -662,6 +662,7 @@ subroutine initai jtp1 logical :: dimok,exists character :: filename*120 + integer :: nfu ! --- Get global coordinates of p-points. call xcaget(tmp2da,plat,1) @@ -708,7 +709,7 @@ subroutine initai filename = 'atm_intwgt.uf' inquire(file=filename,exist = exists) if (exists) then - open (unit=nfu,file=filename,form = 'unformatted') + open (newunit=nfu,file=filename,form = 'unformatted') read (nfu) atm_idm_t,atm_jdm_t,idm_t,jdm_t,atm_nwgt_t if (atm_idm_t == atm_idm.and.atm_jdm_t == atm_jdm.and. & idm_t == itdm.and.jdm_t == jtdm.and. & @@ -839,7 +840,7 @@ subroutine initai end do end if - open (unit=nfu,file=filename,form = 'unformatted') + open (newunit=nfu,file=filename,form = 'unformatted') write (nfu) atm_idm,atm_jdm,itdm,jtdm,atm_nwgt write (nfu) atm_wgt,atm_iwgt,atm_jwgt close (unit = nfu) @@ -1936,10 +1937,11 @@ subroutine rdcsic real*4, dimension(atm_idm,atm_jdm) :: atm_field_r4 real, dimension(itdm,jtdm) :: tmp2d integer :: i,j,k + integer :: nfu if (mnproc == 1) then write (lp,*) 'reading atm. climatological ice concentration...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/icec_1968-1996.uf', & form = 'unformatted') end if @@ -1990,6 +1992,7 @@ subroutine rdctsf real :: dx2,dy2 integer, dimension(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) :: smtmsk integer :: i,j,k,l + integer :: nfu if (mnproc == 1) then write (lp,*) & @@ -2031,7 +2034,7 @@ subroutine rdctsf end if if (mnproc == 1) then - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/skt_1968-1996.uf', & form = 'unformatted') end if @@ -2101,9 +2104,10 @@ subroutine inifrc_ben02clim real :: dx2,dy2,prc_sum,eva_sum,rnf_sum,swa_sum,lwa_sum,lht_sum, & sht_sum,fwf_fac,dangle,garea,le,albedo,fac,swa_ave,lwa_ave, & lht_ave,sht_ave,crnf,cswa,A_cgs2mks - real*4 rw4 + real*4 :: rw4 integer :: i,j,k,l,il,jl - integer*2 rn2,ri2,rj2 + integer*2 :: rn2,ri2,rj2 + integer :: nfu A_cgs2mks = 1./(L_mks2cgs**2) @@ -2239,7 +2243,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write (lp,*) & 'reading atm. climatological short-wave radiation flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/dswrf_1968-1996.uf', & form = 'unformatted') end if @@ -2276,7 +2280,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write (lp,*) & 'reading atm. climatological long-wave radiation flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/nlwrs_1968-1996.uf', & form = 'unformatted') end if @@ -2312,7 +2316,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological total cloud cover...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/tcdc_1968-1996.uf', & form = 'unformatted') end if @@ -2359,7 +2363,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological precipitation rate...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/prate_1968-1996.uf', & form = 'unformatted') end if @@ -2395,7 +2399,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological latent heat flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/lhtfl_1968-1996.uf', & form = 'unformatted') end if @@ -2431,7 +2435,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological sensible heat flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/shtfl_1968-1996.uf', & form = 'unformatted') end if @@ -2469,7 +2473,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write (lp,*) & 'reading atm. climatological surface temperature...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/skt_1968-1996.uf', & form = 'unformatted') @@ -2493,7 +2497,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological surface pressure...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/pres_1968-1996.uf', & form = 'unformatted') end if @@ -2529,7 +2533,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) 'reading atm. climatological momentum flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/momfl_1968-1996.uf', & form = 'unformatted') end if @@ -2564,7 +2568,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) & 'reading atm. climatological u-component of momentum flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/uflx_1968-1996.uf', & form = 'unformatted') end if @@ -2593,7 +2597,7 @@ subroutine inifrc_ben02clim if (mnproc == 1) then write(lp,*) & 'reading atm. climatological v-component of momentum flux...' - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/vflx_1968-1996.uf', & form = 'unformatted') end if @@ -2662,7 +2666,7 @@ subroutine inifrc_ben02clim rnf_ocdpi = 0 rnf_ocdpj = 0 else - open (unit=nfu,file = 'runoffweights.uf', & + open (newunit=nfu,file = 'runoffweights.uf', & form='unformatted',status='old',action = 'read') do j = 1,atm_jdm do i = 1,atm_idm @@ -2688,7 +2692,7 @@ subroutine inifrc_ben02clim close (unit = nfu) end if - open (unit=nfu,file = atm_path(1:atm_path_len) & + open (newunit=nfu,file = atm_path(1:atm_path_len) & //'clim/runof_1968-1996.uf', & form = 'unformatted') end if @@ -2930,9 +2934,10 @@ subroutine inifrc_ben02syn ! --- ------------------------------------------------------------------ real :: dx2,dy2 - real*4 rw4 + real*4 :: rw4 integer :: errstat,i,j,k,l - integer*2 rn2,ri2,rj2 + integer*2 :: rn2,ri2,rj2 + integer :: nfu ! --- Allocate memory for daily forcing fields. allocate(taud (1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy,5), & @@ -3065,7 +3070,7 @@ subroutine inifrc_ben02syn rnf_ocdpi(atm_abdm,atm_idm,atm_jdm), & rnf_ocdpj(atm_abdm,atm_idm,atm_jdm)) - open (unit=nfu,file = 'runoffweights.uf', & + open (newunit=nfu,file = 'runoffweights.uf', & form='unformatted',status='old',action = 'read') do j = 1,atm_jdm do i = 1,atm_idm diff --git a/channel/mod_channel.F90 b/channel/mod_channel.F90 index 350f5a9f..5e283124 100644 --- a/channel/mod_channel.F90 +++ b/channel/mod_channel.F90 @@ -40,31 +40,31 @@ module mod_channel use mod_ben02, only: ntda, alb, albw, dfl use mod_forcing, only: surflx, surrlx, sswflx, salflx, brnflx, salrlx, & taux, tauy, ustarw, slp, swa, atmco2, nsf, mty, & - ztx, hmltfz, eva, lip, sop, rnf, rfi, & + ztx, hmltfz, eva, lip, sop, rnf, rfi, & fmltfz, sfl, abswnd, flxco2, flxdms, sstclm, sssclm !use mod_mxlayr, only: mltmin use mod_state, only: temp, saln, sigma, phi use mod_checksum, only: csdiag, chksummsk - + implicit none - + private - + public :: geoenv_channel, inifrc_channel, ictsz_channel - + contains - + ! --------------------------------------------------------------------------- ! Public procedures. ! --------------------------------------------------------------------------- - + subroutine geoenv_channel ! --------------------------------------------------------------------------- ! Define bathymetry, grid specification and Coriolis parameter for the ! channel configuration ! --------------------------------------------------------------------------- intrinsic random_seed, random_number, tanh, sin - + integer, parameter :: ncorru=10 real(r8), dimension(ncorru) :: acorru, wlcorru real(r8), dimension(1 - nbdy:idm + nbdy, 1 - nbdy:jdm + nbdy) :: r0 @@ -74,7 +74,8 @@ subroutine geoenv_channel integer :: i,j,l,ios integer, dimension(:), allocatable :: seed logical :: fexist - + integer :: nfu + ! Read parameters from the namelist namelist /idlgeo/ sldepth,sfdepth,rdepth,acorru,wlcorru, & cwidth,swidth,scxy,corio0,beta0 @@ -82,17 +83,17 @@ subroutine geoenv_channel wlcorru(:)=0._r8 inquire(file='limits', exist=fexist) if (fexist) then - open (unit=nfu,file='limits',status='old',action='read') + open (newunit=nfu,file='limits',status='old',action='read') else write (lp,*) 'geoenv_channel: could not find namelist file!' call xchalt('(geoenv_channel)') stop '(geoenv_channel)' endif - + read (unit=nfu,nml=idlgeo,iostat=ios) close (unit=nfu) ! Done reading - + ! broadcast the namelist variables call xcbcst(sldepth) call xcbcst(sfdepth) @@ -160,13 +161,13 @@ subroutine geoenv_channel cosang=1._r8 sinang=0._r8 ! initialize depth to 0 - depths(i,j)=0._r8 + depths(i,j)=0._r8 enddo enddo !$omp end parallel do - + ! Set the bottom topography to be a tanh function. - ! The resulting slope will have the same shape independent of the + ! The resulting slope will have the same shape independent of the ! grid size (no interpolation done though). !$omp parallel do private(i,r,l,d_corru) do j=1,jj @@ -205,9 +206,9 @@ subroutine geoenv_channel endif enddo !$omp end parallel do - + end subroutine geoenv_channel - + subroutine ictsz_channel ! define layer temperature and salinity, and geopotential at layer interfaces. real(r8), dimension(1 - nbdy:idm + nbdy, & @@ -218,18 +219,19 @@ subroutine ictsz_channel real(r8) :: S0,sig0,sig0dz,sigdz,sigscl,dztop,dzmax,dzscl integer i,j,k,l,ios logical :: fexist - + integer :: nfu + namelist /idlini/ S0,sig0,sig0dz,sigdz,sigscl,dztop,dzmax,dzscl - + if (mnproc.eq.1) then write (lp,'(1a)') ' idealized initial conditions' call flush(lp) endif - - ! + + ! inquire(file='limits',exist=fexist) if (fexist) then - open (unit=nfu,file='limits',status='old',action='read') + open (newunit=nfu,file='limits',status='old',action='read') else write (lp,*) 'ictsz_channel: could not find namelist file!' call xchalt('(ictsz_channel)') @@ -319,28 +321,29 @@ subroutine ictsz_channel enddo enddo !$omp end parallel do - + end subroutine ictsz_channel - + subroutine inifrc_channel ! --------------------------------------------------- ! Define forcing - This could be used as a getfrc ! function as well if time varying forcing is desired ! (time dependency would need to be added). ! --------------------------------------------------- - + intrinsic tanh - + real(r8) :: ztx0,mty0,sst0,sss0 - integer i,j,l,k,ios + integer :: i,j,l,k,ios logical :: fexist - + integer :: nfu + namelist /idlfor/ ztx0,mty0,sst0,sss0 - + ! --- READ NAMELIST FILE inquire(file='limits',exist=fexist) if (fexist) then - open (unit=nfu,file='limits',status='old',action='read') + open (newunit=nfu,file='limits',status='old',action='read') else write (lp,*) 'inifrc_channel: could not find namelist file!' call xchalt('(inifrc_channel)') @@ -372,7 +375,7 @@ subroutine inifrc_channel !alb(i,j) = 0._r8 ! albedo eva(i,j) = 0._r8 ! evaporation lip(i,j) = 0._r8 ! liquid precip - sop(i,j) = 0._r8 ! solid precip + sop(i,j) = 0._r8 ! solid precip rnf(i,j) = 0._r8 ! runoff rfi(i,j) = 0._r8 ! runoff ice fmltfz(i,j) = 0._r8 ! fresh water flux due to melting/freezing @@ -384,8 +387,8 @@ subroutine inifrc_channel ! ! ------------------------------------------------- ! SST and SSS climatologies are set here (to values - ! defined in the namelist), but their usage is controlled - ! by namelist timescales that are 0. by default. + ! defined in the namelist), but their usage is controlled + ! by namelist timescales that are 0. by default. ! ------------------------------------------------- ! do k=1,12 @@ -406,18 +409,18 @@ subroutine inifrc_channel enddo enddo !$omp end parallel do - - + + end subroutine inifrc_channel - + subroutine icaux_channel - ! This is mostly an empty subroutine, + ! This is mostly an empty subroutine, ! but could be used to setup sea ice - + ntda=0 - + end subroutine icaux_channel - + subroutine sfcstr_channel(m,n,mm,nn,k1m,k1n) ! ! ----------------------------------------------------------------- @@ -454,5 +457,5 @@ subroutine sfcstr_channel(m,n,mm,nn,k1m,k1n) endif ! end subroutine sfcstr_channel - + end module mod_channel diff --git a/cime_config/buildnml b/cime_config/buildnml index 757a8470..6ef0f906 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -322,21 +322,6 @@ def buildnml(case, caseroot, compname): fwrite.write(line) shutil.move(namelist_file_temp, namelist_file) - # change xml variable settings if appropriate - # Note - this does not change the blom namelist - it changes xml variables that are then - # used by cmeps to change attributes that are sent to the atm - # TODO: add n2o_emis and nh3_emis logic - if comp_interface == "nuopc": - if "ecosys" in case.get_value("BLOM_TRACER_MODULES"): - dms_emis = case.get_value("DMS_EMIS_OCN") - if dms_emis is not None: - case.set_value('DMS_EMIS_OCN','TRUE') - print (" ***Setting DMS_EMIS_OCN to TRUE***") - brf_emis = pg_blom.get_value('use_bromo') - if brf_emis == ".true.": - case.set_value('BRF_EMIS_OCN','TRUE') - print (" ***Setting BRF_EMIS_OCN to TRUE***") - ############################################################################### def _main_func(): diff --git a/drivers/mct/ocn_comp_mct.F90 b/drivers/mct/ocn_comp_mct.F90 index f8712ece..4b53f0d5 100644 --- a/drivers/mct/ocn_comp_mct.F90 +++ b/drivers/mct/ocn_comp_mct.F90 @@ -49,7 +49,7 @@ module ocn_comp_mct use mod_config, only: inst_index, inst_name, inst_suffix, resume_flag use mod_time, only: blom_time, nstep, baclin, delt1, dlt use mod_cesm, only: runid_cesm, runtyp_cesm, ocn_cpl_dt_cesm - use mod_xc, only: mnproc, mpicom_external, xctilr, nfu, lp, nbdy, & + use mod_xc, only: mnproc, mpicom_external, xctilr, lp, nbdy, & ii, jj, kk, i0, j0, nproc, jpr, cplmsk, halo_ps, & ifu, ilu, isv, ifv, ilv, isp, ifp, ilp, isu use mod_blom_init, only: blom_init @@ -119,9 +119,6 @@ subroutine ocn_init_mct(EClock, cdata_o, x2o_o, o2x_o, NLFilename) ! Set communicator to be used by blom mpicom_external = mpicom_ocn - ! Get file unit - nfu = shr_file_getUnit() - ! Get multiple instance data inst_name = seq_comm_name(OCNID) inst_index = seq_comm_inst(OCNID) diff --git a/drivers/nocoupler/blom.F b/drivers/nocoupler/blom.F index 2e24d684..83e05b7c 100644 --- a/drivers/nocoupler/blom.F +++ b/drivers/nocoupler/blom.F @@ -31,6 +31,8 @@ program blom use mod_blom_step, only: blom_step c implicit none + + integer :: nfu c c --- initialize the model call blom_init @@ -45,7 +47,7 @@ program blom call chksummsk(dp(1-nbdy,1-nbdy,1+mod(nstep2,2)*kk),ip,kk,'dp') c if (mnproc.eq.1) then - open (unit=nfu,file='run.status',status='unknown') + open (newunit=nfu,file='run.status',status='unknown') write (nfu,*) 'success' close (unit=nfu) endif diff --git a/drivers/noforc/blom.F b/drivers/noforc/blom.F index a665cb4b..c583c3e3 100644 --- a/drivers/noforc/blom.F +++ b/drivers/noforc/blom.F @@ -38,13 +38,14 @@ program blom #endif c integer i + integer nfu c #ifdef MPI call mpi_init mpicom_external=mpi_comm_world #endif c - open (unit=nfu,file='ocn_in',status='old',action='read') + open (newunit=nfu,file='ocn_in',status='old',action='read') read (nfu,'(i6)') i read (nfu,*) read (nfu,*) @@ -71,7 +72,7 @@ program blom call chksummsk(dp(1-nbdy,1-nbdy,1+mod(nstep2,2)*kk),ip,1,'dp') c if (mnproc.eq.1) then - open (unit=nfu,file='run.status',status='unknown') + open (newunit=nfu,file='run.status',status='unknown') write (nfu,*) 'success' close (unit=nfu) endif diff --git a/drivers/nuopc/ocn_comp_nuopc.F90 b/drivers/nuopc/ocn_comp_nuopc.F90 index ca588fe9..3c101f59 100644 --- a/drivers/nuopc/ocn_comp_nuopc.F90 +++ b/drivers/nuopc/ocn_comp_nuopc.F90 @@ -22,42 +22,45 @@ module ocn_comp_nuopc ! This module contains the NUOPC cap for BLOM. ! ------------------------------------------------------------------------------ - use ESMF ! TODO MOM6 uses "only" statements, while POP and CICE omits this. - use NUOPC, only: NUOPC_CompDerive, NUOPC_CompSetEntryPoint, & - NUOPC_CompSpecialize, NUOPC_CompFilterPhaseMap, & - NUOPC_IsUpdated, NUOPC_IsAtTime, NUOPC_CompAttributeGet, & - NUOPC_Advertise, NUOPC_SetAttribute, & - NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, & - NUOPC_IsConnected, NUOPC_Realize - use NUOPC_Model, only: NUOPC_ModelGet, SetVM, & - model_routine_SS => SetServices, & - model_label_Advance => label_Advance, & - model_label_DataInitialize => label_DataInitialize, & - model_label_SetRunClock => label_SetRunClock, & - model_label_Finalize => label_Finalize - use nuopc_shr_methods, only : ChkErr, set_component_logging, & - get_component_instance, state_setscalar, & - alarmInit - use shr_cal_mod, only : shr_cal_ymd2date - use shr_file_mod, only: shr_file_getUnit, shr_file_getLogUnit, shr_file_setLogUnit - use mod_nuopc_methods, only: fldlist_type, fldsMax, tlast_coupled, & + use ESMF ! TODO add " only" statements + use NUOPC, only: NUOPC_CompDerive, NUOPC_CompSetEntryPoint, & + NUOPC_CompSpecialize, NUOPC_CompFilterPhaseMap, & + NUOPC_IsUpdated, NUOPC_IsAtTime, NUOPC_CompAttributeGet, & + NUOPC_Advertise, NUOPC_SetAttribute, & + NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, & + NUOPC_IsConnected, NUOPC_Realize + use NUOPC_Model, only: NUOPC_ModelGet, SetVM, & + model_routine_SS => SetServices, & + model_label_Advance => label_Advance, & + model_label_DataInitialize => label_DataInitialize, & + model_label_SetRunClock => label_SetRunClock, & + model_label_Finalize => label_Finalize + use nuopc_shr_methods, only: ChkErr, set_component_logging, & + get_component_instance, state_setscalar, & + alarmInit + use shr_cal_mod, only: shr_cal_ymd2date + use shr_log_mod, only: shr_log_getLogUnit, shr_log_setLogUnit + use ocn_import_export, only: fldlist_type, fldsMax, tlast_coupled, & blom_logwrite, blom_getgindex, blom_checkmesh, & blom_setareacor, blom_getglobdim, & blom_getprecipfact, blom_accflds, & blom_importflds, blom_exportflds, & blom_advertise_imports, blom_advertise_exports - use mod_xc, only: mpicom_external, lp, nfu - use mod_cesm, only: runid_cesm, runtyp_cesm, ocn_cpl_dt_cesm - use mod_config, only: inst_index, inst_name, inst_suffix - use mod_time, only: blom_time - use mod_forcing, only : srxday, trxday - use mod_constants, only : epsilt - use mod_blom_init, only : blom_init - use mod_blom_step, only : blom_step - use mod_fill_global, only : fill_global - use mod_restart, only : restart_write - use ocn_stream_sss, only : ocn_stream_sss_init, ocn_stream_sss_interp - use ocn_stream_sst, only : ocn_stream_sst_init, ocn_stream_sst_interp + use mod_xc, only: mpicom_external, lp, xchalt + use mod_cesm, only: runid_cesm, runtyp_cesm, ocn_cpl_dt_cesm + use mod_config, only: inst_index, inst_name, inst_suffix + use mod_time, only: blom_time + use mod_forcing, only: srxday, trxday + use mod_constants, only: epsilt + use mod_blom_init, only: blom_init + use mod_blom_step, only: blom_step + use mod_fill_global, only: fill_global + use mod_restart, only: restart_write + use ocn_stream_sss, only: ocn_stream_sss_init, ocn_stream_sss_interp + use ocn_stream_sst, only: ocn_stream_sst_init, ocn_stream_sst_interp +#ifdef HAMOCC + use mo_control_bgc, only: use_BROMO +#endif implicit none @@ -80,8 +83,6 @@ module ocn_comp_nuopc integer :: flds_scalar_index_ny = 0 integer :: flds_scalar_index_precip_factor = 0 - logical :: ocn2glc_coupling, flds_dms_med - integer :: dbug = 0 logical :: profile_memory = .false. @@ -376,7 +377,19 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) character(len=cslen) :: starttype, stdname character(len=cllen) :: msg, cvalue logical :: isPresent, isSet - logical :: flds_co2a, flds_co2c + logical :: ocn2glc_coupling + logical :: flds_co2a, flds_co2c, flds_dms, flds_brf + logical :: hamocc_defined +#ifndef HAMOCC + logical :: use_BROMO +#endif + +#ifdef HAMOCC + hamocc_defined = .true. +#else + hamocc_defined = .false. + use_BROMO = .false. +#endif ! Get debug flag. call NUOPC_CompAttributeGet(gcomp, name='dbug_flag', value=cvalue, & @@ -407,13 +420,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call set_component_logging(gcomp, localPet==0, lp, shrlogunit, rc) if (ChkErr(rc, __LINE__, u_FILE_u)) return - ! Get generic file unit for master task. - if (localPet == 0) then - nfu = shr_file_getUnit() - else - nfu = -1 - endif - ! Get case name. call NUOPC_CompAttributeGet(gcomp, name='case_name', value=cvalue, rc=rc) if (ChkErr(rc, __LINE__, u_FILE_u)) return @@ -532,6 +538,51 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) !NOTE: Nitrogen deposition is always sent from atm now (either CAM or DATM) + ! Determine if will export dms + call NUOPC_CompAttributeGet(gcomp, name='flds_dms', value=cvalue, & + ispresent=ispresent, isset=isset, rc=rc) + if (ChkErr(rc, __LINE__, u_FILE_u)) return + if (isPresent .and. isSet) then + read(cvalue,*) flds_dms + if (.not. hamocc_defined) then + ! if not defined HAMOCC and request to export dms, abort + if (flds_dms) then + write(lp,'(a)') subname//' cannot export dms with out HAMOCC defined' + call xchalt(subname) + stop subname + end if + end if + else + flds_dms = .false. + end if + write(msg,'(a,l1)') subname//': export dms ', flds_dms + call blom_logwrite(msg) + + ! Determine if will export bromoform + call NUOPC_CompAttributeGet(gcomp, name="flds_brf", value=cvalue, & + ispresent=ispresent, isset=isset, rc=rc) + if (ChkErr(rc, __LINE__, u_FILE_u)) return + if (isPresent .and. isSet) then + read(cvalue,*) flds_brf + if (hamocc_defined) then + ! make sure that use_BROMO is true if ask for bromoform to be sent to mediator + if (flds_brf .and. .not. use_BROMO) then + write(lp,'(a)') subname//' cannot export bromoform if use_BROMO is not true' + call xchalt(subname) + stop subname + end if + else + ! if not defined HAMOCC and request to export brf, abort + if (flds_brf) then + write(lp,'(a)') subname//' cannot export bromoform with out HAMOCC defined' + call xchalt(subname) + stop subname + end if + end if + end if + write(msg,'(a,l1)') subname//': export brf ', flds_brf + call blom_logwrite(msg) + ! ------------------------------------------------------------------------ ! Advertise import fields. ! ------------------------------------------------------------------------ @@ -549,7 +600,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! Advertise export fields. ! ------------------------------------------------------------------------ - call blom_advertise_exports(flds_scalar_name, fldsFrOcn_num, fldsFrOcn, ocn2glc_coupling) + call blom_advertise_exports(flds_scalar_name, fldsFrOcn_num, fldsFrOcn, ocn2glc_coupling, & + flds_dms, flds_brf) do n = 1,fldsFrOcn_num call NUOPC_Advertise(exportState, standardName=fldsFrOcn(n)%stdname, & @@ -771,7 +823,7 @@ subroutine ModelAdvance(gcomp, rc) ! Local variables. type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock - type(ESMF_Time) :: currTime + type(ESMF_Time) :: currTime type(ESMF_Alarm) :: restart_alarm integer :: shrlogunit, yr_sync, mon_sync, day_sync, tod_sync, ymd_sync, & ymd, tod @@ -786,8 +838,8 @@ subroutine ModelAdvance(gcomp, rc) ! Reset shr logging to components log file. ! ------------------------------------------------------------------------ - call shr_file_getLogUnit(shrlogunit) - call shr_file_setLogUnit(lp) + call shr_log_getLogUnit(shrlogunit) + call shr_log_setLogUnit(lp) ! ------------------------------------------------------------------------ ! Skip first coupling interval for an initial run. @@ -895,7 +947,7 @@ subroutine ModelAdvance(gcomp, rc) ! Reset shr logging to original values. ! ------------------------------------------------------------------------ - call shr_file_setLogUnit(shrlogunit) + call shr_log_setLogUnit(shrlogunit) if (dbug > 5) call ESMF_LogWrite(subname//': done', ESMF_LOGMSG_INFO) diff --git a/drivers/nuopc/ocn_import_export.F90 b/drivers/nuopc/ocn_import_export.F90 index e95d1917..fdcd1611 100644 --- a/drivers/nuopc/ocn_import_export.F90 +++ b/drivers/nuopc/ocn_import_export.F90 @@ -17,7 +17,7 @@ ! along with BLOM. If not, see . ! ------------------------------------------------------------------------------ -module mod_nuopc_methods +module ocn_import_export ! ------------------------------------------------------------------------------ ! This module contains routines operating on BLOM data structures needed by the ! NUOPC cap. @@ -273,7 +273,7 @@ subroutine blom_advertise_imports(flds_scalar_name, fldsToOcn_num, fldsToOcn, & end subroutine blom_advertise_imports subroutine blom_advertise_exports(flds_scalar_name, fldsFrOcn_num, fldsFrOcn, & - ocn2glc_coupling) + ocn2glc_coupling, flds_dms, flds_brf) ! ------------------------------------------------------------------- ! Determine fldsToOcn for export fields ! ------------------------------------------------------------------- @@ -282,6 +282,8 @@ subroutine blom_advertise_exports(flds_scalar_name, fldsFrOcn_num, fldsFrOcn, & integer , intent(inout) :: fldsFrOcn_num type(fldlist_type) , intent(inout) :: fldsFrOcn(:) logical , intent(in) :: ocn2glc_coupling + logical , intent(in) :: flds_dms + logical , intent(in) :: flds_brf ! Local variables integer :: index_scalar @@ -299,12 +301,14 @@ subroutine blom_advertise_exports(flds_scalar_name, fldsFrOcn_num, fldsFrOcn, & call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Fioo_q' , index_Fioo_q) call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fco2_ocn' , index_Faoo_fco2) #ifdef HAMOCC - call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fdms_ocn' , index_Faoo_fdms) - call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fn2o_ocn' , index_Faoo_fn2o) - call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fnh3_ocn' , index_Faoo_fnh3) - if (use_BROMO) then + if (flds_dms) then + call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fdms_ocn', index_Faoo_fdms) + end if + if (flds_brf) then call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fbrf_ocn', index_Faoo_fbrf) end if + call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fn2o_ocn' , index_Faoo_fn2o) + call fldlist_add(fldsFrOcn_num, fldsFrOcn, 'Faoo_fnh3_ocn' , index_Faoo_fnh3) #endif if (ocn2glc_coupling) then call fldList_add(fldsFrOcn_num, fldsFrOcn, 'So_t_depth', index_So_t_depth, & @@ -1238,4 +1242,4 @@ subroutine blom_exportflds(fldlist_num, fldlist) end subroutine blom_exportflds -end module mod_nuopc_methods +end module ocn_import_export diff --git a/hamocc/mo_hamocc_init.F90 b/hamocc/mo_hamocc_init.F90 index b43d9460..a4d72e8f 100644 --- a/hamocc/mo_hamocc_init.F90 +++ b/hamocc/mo_hamocc_init.F90 @@ -36,7 +36,7 @@ subroutine hamocc_init(read_rest,rstfnm_hamocc) !*********************************************************************************************** use mod_time, only: date,baclin - use mod_xc, only: ii,jj,kk,idm,jdm,kdm,nbdy,isp,ifp,ilp,mnproc,lp,nfu,xchalt + use mod_xc, only: ii,jj,kk,idm,jdm,kdm,nbdy,isp,ifp,ilp,mnproc,lp,xchalt use mod_grid, only: plon,plat use mod_tracers, only: ntrbgc,ntr,itrbgc,trc use mo_control_bgc, only: bgc_namelist,get_bgc_namelist,do_ndep,do_rivinpt,do_oalk, & diff --git a/phy/mod_budget.F90 b/phy/mod_budget.F90 index 9a855c56..515adfdc 100644 --- a/phy/mod_budget.F90 +++ b/phy/mod_budget.F90 @@ -186,6 +186,7 @@ subroutine budget_output(m) integer, intent(in) :: m integer :: i, j,l + integer :: nfu if (.not.cnsvdi) return @@ -193,7 +194,7 @@ subroutine budget_output(m) if (vcoord_type_tag == isopyc_bulkml) then - open (unit = nfu, file = 'salbud', position = 'append') + open (newunit = nfu, file = 'salbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (sdp(2, m) - sdp(1, m))/mass0, & (sdp(3, m) - sdp(2, m))/mass0, & @@ -202,7 +203,7 @@ subroutine budget_output(m) (sdp(6, m) - sdp(5, m))/mass0, & (sdp(7, m) - sdp(6, m))/mass0 close (nfu) - open (unit = nfu, file = 'tembud', position = 'append') + open (newunit = nfu, file = 'tembud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (tdp(2, m) - tdp(1, m))/mass0, & (tdp(3, m) - tdp(2, m))/mass0, & @@ -213,7 +214,7 @@ subroutine budget_output(m) close (nfu) if (use_TRC) then if (use_TKE) then - open (unit = nfu, file = 'tkebud', position = 'append') + open (newunit = nfu, file = 'tkebud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (tkedp(2, m) - tkedp(1, m))/mass0, & (tkedp(3, m) - tkedp(2, m))/mass0, & @@ -223,7 +224,7 @@ subroutine budget_output(m) (tkedp(7, m) - tkedp(6, m))/mass0 close (nfu) if (use_GLS) then - open (unit = nfu, file = 'glsbud', position = 'append') + open (newunit = nfu, file = 'glsbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (glsdp(2, m) - glsdp(1, m))/mass0, & (glsdp(3, m) - glsdp(2, m))/mass0, & @@ -234,7 +235,7 @@ subroutine budget_output(m) close (nfu) end if end if - open (unit = nfu, file = 'trcbud', position = 'append') + open (newunit = nfu, file = 'trcbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (trdp(2, m) - trdp(1, m))/mass0, & (trdp(3, m) - trdp(2, m))/mass0, & @@ -243,7 +244,7 @@ subroutine budget_output(m) (trdp(6, m) - trdp(5, m))/mass0, & (trdp(7, m) - trdp(6, m))/mass0 close (nfu) - open (unit = nfu, file = 'trcbudtot', position = 'append') + open (newunit = nfu, file = 'trcbudtot', position = 'append') write (nfu, '(i8,7e18.10)') nstep - 1, & trdp(1, m)/mass0, trdp(2, m)/mass0, trdp(3, m)/mass0, & trdp(4, m)/mass0, trdp(5, m)/mass0, trdp(6, m)/mass0, & @@ -253,7 +254,7 @@ subroutine budget_output(m) else - open (unit = nfu, file = 'salbud', position = 'append') + open (newunit = nfu, file = 'salbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (sdp(2, m) - sdp(1, m))/mass0, & (sdp(3, m) - sdp(2, m))/mass0, & @@ -262,7 +263,7 @@ subroutine budget_output(m) (sdp(6, m) - sdp(5, m))/mass0, & (sdp(7, m) - sdp(6, m))/mass0 close (nfu) - open (unit = nfu, file = 'tembud', position = 'append') + open (newunit = nfu, file = 'tembud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (tdp(2, m) - tdp(1, m))/mass0, & (tdp(3, m) - tdp(2, m))/mass0, & @@ -273,7 +274,7 @@ subroutine budget_output(m) close (nfu) if (use_TRC) then if (use_TKE) then - open (unit = nfu, file = 'tkebud', position = 'append') + open (newunit = nfu, file = 'tkebud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (tkedp(2, m) - tkedp(1, m))/mass0, & (tkedp(3, m) - tkedp(2, m))/mass0, & @@ -283,7 +284,7 @@ subroutine budget_output(m) (tkedp(7, m) - tkedp(6, m))/mass0 close (nfu) if (use_GLS) then - open (unit = nfu, file = 'glsbud', position = 'append') + open (newunit = nfu, file = 'glsbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (glsdp(2, m) - glsdp(1, m))/mass0, & (glsdp(3, m) - glsdp(2, m))/mass0, & @@ -294,7 +295,7 @@ subroutine budget_output(m) close (nfu) end if end if - open (unit = nfu, file = 'trcbud', position = 'append') + open (newunit = nfu, file = 'trcbud', position = 'append') write (nfu, '(i8,6e12.4)') nstep - 1, & (trdp(2, m) - trdp(1, m))/mass0, & (trdp(3, m) - trdp(2, m))/mass0, & @@ -303,7 +304,7 @@ subroutine budget_output(m) (trdp(6, m) - trdp(5, m))/mass0, & (trdp(7, m) - trdp(6, m))/mass0 close (nfu) - open (unit = nfu, file = 'trcbudtot', position = 'append') + open (newunit = nfu, file = 'trcbudtot', position = 'append') write (nfu, '(i8,7e18.10)') nstep - 1, & trdp(1, m)/mass0, trdp(2, m)/mass0, trdp(3, m)/mass0, & trdp(4, m)/mass0, trdp(5, m)/mass0, trdp(6, m)/mass0, & diff --git a/phy/mod_dia.F90 b/phy/mod_dia.F90 index e831b5d1..d6eaac3a 100644 --- a/phy/mod_dia.F90 +++ b/phy/mod_dia.F90 @@ -35,7 +35,7 @@ module mod_dia xceget, xctilr, xcsum, & isp, ifp, ilp, isu, ifu, ilu, isv, ifv, ilv, & isu, ifu, ilu, isv, ip, halo_ps, ipwocn, & - iu, iv, nfu, ips, halo_qs, halo_uv, halo_vv + iu, iv, ips, halo_qs, halo_uv, halo_vv use mod_nctools use netcdf, only: nf90_fill_double use mod_vcoord, only: vcoord_type_tag, isopyc_bulkml, & @@ -3369,6 +3369,7 @@ subroutine diasec(iogrp) real, dimension(itdm,jtdm) :: & uflx_cumt,vflx_cumt,uflx_cum350t,vflx_cum350t real(8) :: volu,volv + integer :: nfu !--------------------------------------------------------------- ! read section information @@ -3376,7 +3377,7 @@ subroutine diasec(iogrp) if (iniflg) then if (mnproc == 1) then equat_sec = -1 - open(nfu,file=sec_sifile,status = 'old') + open(newunit=nfu,file=sec_sifile,status = 'old') sec_num = 0 do read(nfu,'(a120)',iostat = iostatus) char120 @@ -3515,6 +3516,7 @@ subroutine diamer(iogrp) real :: r character :: c20*20 logical :: iniflg = .true. + integer :: nfu save nind,iind,jind,oflg,uflg,vflg,depthst,iniflg,ocn_nreg @@ -3540,7 +3542,7 @@ subroutine diamer(iogrp) call ncerro(nf90_close(ncid)) ! Read section file metra_index.dat - open(nfu,file=mer_mifile,status = 'old') + open(newunit=nfu,file=mer_mifile,status = 'old') lmax = 0 do l = 1,ldm c20 = ' ' diff --git a/phy/mod_diffusion.F90 b/phy/mod_diffusion.F90 index 7931fef8..a43cdd9c 100644 --- a/phy/mod_diffusion.F90 +++ b/phy/mod_diffusion.F90 @@ -197,6 +197,7 @@ subroutine readnml_diffusion character(len = 80) :: nml_fname integer :: ios logical :: fexist + integer :: nfu namelist /diffusion/ & egc, eggam, eglsmn, egmndf, egmxdf, egidfq, rhiscf, ri0, & @@ -208,12 +209,13 @@ subroutine readnml_diffusion nml_fname = 'ocn_in'//trim(inst_suffix) inquire(file = nml_fname, exist = fexist) if (fexist) then - open (unit = nfu, file = nml_fname, status = 'old', action = 'read') + open (newunit = nfu, file = nml_fname, status = 'old', & + action = 'read') else nml_fname = 'limits'//trim(inst_suffix) inquire(file = nml_fname, exist = fexist) if (fexist) then - open (unit = nfu, file = nml_fname, status = 'old', & + open (newunit = nfu, file = nml_fname, status = 'old', & action = 'read') else write (lp,*) 'readnml_diffusion: could not find namelist file!' diff --git a/phy/mod_geoenv.F90 b/phy/mod_geoenv.F90 index 44725729..40c77898 100644 --- a/phy/mod_geoenv.F90 +++ b/phy/mod_geoenv.F90 @@ -23,7 +23,7 @@ module mod_geoenv use mod_config, only: inst_suffix use mod_constants, only: rearth, pi, radian, L_mks2cgs use mod_xc, only: xchalt, xcaput, xcbcst, itdm, jtdm, & - lp, nbdy, nfu, i0, ii, j0, jj, mnproc + lp, nbdy, i0, ii, j0, jj, mnproc use mod_diffusion, only: rhsctp, tbfile use mod_grid, only: grfile, qclon, qclat, pclon, pclat, uclon, & uclat, vclon, vclat, scqx, scqy, scpx, scpy, & @@ -59,6 +59,7 @@ subroutine geoenv_file integer, dimension(3) :: start,count integer :: i,j,k,status,ncid,dimid,varid,ios,ncwm,l logical :: fexist + integer :: nfu real, parameter :: iL_mks2cgs = 1./L_mks2cgs namelist /cwmod/ cwmtag,cwmedg,cwmi,cwmj,cwmwth @@ -781,12 +782,12 @@ subroutine geoenv_file nlfnm = 'ocn_in'//trim(inst_suffix) inquire(file=nlfnm,exist = fexist) if (fexist) then - open (unit=nfu,file=nlfnm,status='old',action = 'read') + open (newunit=nfu,file=nlfnm,status='old',action = 'read') else nlfnm = 'limits'//trim(inst_suffix) inquire(file=nlfnm,exist = fexist) if (fexist) then - open (unit=nfu,file=nlfnm,status='old',action = 'read') + open (newunit=nfu,file=nlfnm,status='old',action = 'read') else write (lp,*) 'geoenv_file: could not find namelist file!' call xchalt('(geoenv_file)') diff --git a/phy/mod_idarlx.F90 b/phy/mod_idarlx.F90 index 4b23423d..aa50f3c6 100644 --- a/phy/mod_idarlx.F90 +++ b/phy/mod_idarlx.F90 @@ -20,7 +20,7 @@ module mod_idarlx use dimensions, only: itdm, jtdm - use mod_xc, only: xchalt, xcaput, xctilr, mnproc, nfu, lp, nbdy, & + use mod_xc, only: xchalt, xcaput, xctilr, mnproc, lp, nbdy, & ii, jj, halo_ps use mod_forcing, only: tflxap, sflxap, tflxdi, sflxdi, nflxdi, & aptflx, apsflx, ditflx, disflx @@ -41,10 +41,11 @@ subroutine idarlx() ! Local varaibles real, dimension(itdm,jtdm) :: tmp2d integer :: i,j,k + integer :: nfu if (aptflx) then if (mnproc == 1) then - open (unit=nfu,file='tflxdi.uf',form = 'unformatted') + open (newunit=nfu,file='tflxdi.uf',form = 'unformatted') read (nfu) i,j if (i /= itdm.or.j /= jtdm) then write (lp,*) 'wrong dimensions in tflxdi.uf' @@ -65,7 +66,7 @@ subroutine idarlx() end if if (apsflx) then if (mnproc == 1) then - open (unit=nfu,file='sflxdi.uf',form = 'unformatted') + open (newunit=nfu,file='sflxdi.uf',form = 'unformatted') read (nfu) i,j if (i /= itdm.or.j /= jtdm) then write (lp,*) 'wrong dimensions in sflxdi.uf' diff --git a/phy/mod_rdlim.F90 b/phy/mod_rdlim.F90 index c522c49f..15134883 100644 --- a/phy/mod_rdlim.F90 +++ b/phy/mod_rdlim.F90 @@ -28,8 +28,7 @@ module mod_rdlim nstep2, nstep, lstep, nstep_in_day, time0, & time, baclin, batrop, init_timevars, & set_day_of_year, step_time - use mod_xc, only: xcbcst, xchalt, xcstop, mnproc, & - nfu, lp + use mod_xc, only: xcbcst, xchalt, xcstop, mnproc, lp use mod_grid, only: grfile use mod_eos, only: pref use mod_inicon, only: icfile @@ -126,6 +125,7 @@ subroutine rdlim() character(len = 256) :: nlfnm,runtyp,rstfnm logical :: fexist integer :: m,n,idate,idate0,ios + integer :: nfu namelist /limits/ nday1,nday2,idate,idate0,runid,expcnf,runtyp, & grfile,icfile,pref,baclin,batrop, & @@ -152,12 +152,12 @@ subroutine rdlim() nlfnm = 'ocn_in'//trim(inst_suffix) inquire(file=nlfnm,exist = fexist) if (fexist) then - open (unit=nfu,file=nlfnm,status='old',action='read',recl = 80) + open (newunit=nfu,file=nlfnm,status='old',action='read',recl = 80) else nlfnm = 'limits'//trim(inst_suffix) inquire(file=nlfnm,exist = fexist) if (fexist) then - open (unit=nfu,file=nlfnm,status='old',action = 'read', & + open (newunit=nfu,file=nlfnm,status='old',action = 'read', & recl = 80) else write (lp,*) 'rdlim: could not find namelist file!' @@ -368,7 +368,7 @@ subroutine rdlim() if (mnproc == 1) then GLB_AVEPERIO(:) = -999 - open (unit=nfu,file=nlfnm,status='old',action='read',recl = 80) + open (newunit=nfu,file=nlfnm,status='old',action='read',recl = 80) read (unit=nfu,nml=DIAPHY,iostat = ios) close (unit = nfu) @@ -819,7 +819,7 @@ subroutine rdlim() if (mnproc == 1) then - open (unit=nfu,file=nlfnm,status='old',action='read',recl = 80) + open (newunit=nfu,file=nlfnm,status='old',action='read',recl = 80) read (unit=nfu,nml=MERDIA,iostat = ios) close (unit = nfu) if (ios /= 0) then @@ -873,7 +873,7 @@ subroutine rdlim() if (mnproc == 1) then - open (unit=nfu,file=nlfnm,status='old',action='read',recl = 80) + open (newunit=nfu,file=nlfnm,status='old',action='read',recl = 80) read (unit=nfu,nml=SECDIA,iostat = ios) close (unit = nfu) if (ios /= 0) then @@ -971,7 +971,7 @@ subroutine rdlim() stop '(rdlim)' end if if (mnproc == 1) then - open (unit=nfu,file = 'rpointer.ocn'//trim(inst_suffix)) + open (newunit=nfu,file = 'rpointer.ocn'//trim(inst_suffix)) read (nfu,'(a)') rstfnm close (unit = nfu) inquire(file=rstfnm,exist = fexist) diff --git a/phy/mod_restart.F90 b/phy/mod_restart.F90 index 3d62bc4d..4665ea1b 100644 --- a/phy/mod_restart.F90 +++ b/phy/mod_restart.F90 @@ -1041,6 +1041,7 @@ subroutine restart_write character(len = 256), dimension(4) :: rstdate_str character(len = 256) :: rstfnm, fnm character(len = 2) :: c2 + integer :: nfu ! Formulate restart filename. if (expcnf == 'cesm') then @@ -1064,7 +1065,7 @@ subroutine restart_write trim(runid), '_restphy_', & mod(nint(min(nstep/rstfrq, time)) - 1, 3) + 1, '.nc' endif - open(unit = nfu, file = 'rstdate.txt') + open(newunit = nfu, file = 'rstdate.txt') i = 1 300 read(nfu, '(a)', end = 301) rstdate_str(i) i = i + 1 @@ -1076,12 +1077,12 @@ subroutine restart_write ', integration day ', nint(time) if (mnproc == 1) then if (i == 1) then - open(unit = nfu, file = 'rstdate.txt') + open(newunit = nfu, file = 'rstdate.txt') write(nfu, '(a)') rstdate_str(1)(1:len_trim(runid) + 54) close(unit = nfu) elseif (rstdate_str(max(1, i - 2)) /= rstdate_str(i) .and. & rstdate_str(i - 1 ) /= rstdate_str(i)) then - open(unit = nfu, file = 'rstdate.txt') + open(newunit = nfu, file = 'rstdate.txt') do j = max(1, i - 2), i write(nfu, '(a)') rstdate_str(j)(1:len_trim(runid) + 54) enddo @@ -1265,7 +1266,7 @@ subroutine restart_write if (expcnf == 'cesm' .or. expcnf == 'channel') then ! Write restart filename to rpointer.ocn. if (mnproc == 1) then - open(unit = nfu, file = 'rpointer.ocn'//trim(inst_suffix)) + open(newunit = nfu, file = 'rpointer.ocn'//trim(inst_suffix)) write(nfu, '(a)') rstfnm close(unit = nfu) endif @@ -1284,6 +1285,7 @@ subroutine restart_read character(len = 2) :: c2 real(r8) :: pb_max, phi_min, rho_restart logical :: file_exist, fld_read + integer :: nfu ! Open restart file and adjust time information if needed. if (nday1 + nint(time0) == 0 .and. (.not.resume_flag)) then @@ -1315,7 +1317,7 @@ subroutine restart_read call xcbcst(file_exist) if (file_exist) then if (mnproc == 1) then - open(unit = nfu, file = 'rpointer.ocn'//trim(inst_suffix)) + open(newunit = nfu, file = 'rpointer.ocn'//trim(inst_suffix)) read(nfu, '(a)') rstfnm close(unit = nfu) endif diff --git a/phy/mod_vcoord.F90 b/phy/mod_vcoord.F90 index 2d09876d..f2d8acfb 100644 --- a/phy/mod_vcoord.F90 +++ b/phy/mod_vcoord.F90 @@ -930,6 +930,7 @@ subroutine readnml_vcoord character(len = 80) :: nml_fname integer :: ios logical :: fexist + integer :: nfu namelist /vcoord/ & vcoord_type, reconstruction_method, upper_bndr_ord, lower_bndr_ord, & @@ -945,12 +946,13 @@ subroutine readnml_vcoord nml_fname = 'ocn_in'//trim(inst_suffix) inquire(file = nml_fname, exist = fexist) if (fexist) then - open (unit = nfu, file = nml_fname, status = 'old', action = 'read') + open (newunit = nfu, file = nml_fname, status = 'old', & + action = 'read') else nml_fname = 'limits'//trim(inst_suffix) inquire(file = nml_fname, exist = fexist) if (fexist) then - open (unit = nfu, file = nml_fname, status = 'old', & + open (newunit = nfu, file = nml_fname, status = 'old', & action = 'read') else write (lp,*) 'readnml_vcoord: could not find namelist file!' diff --git a/phy/mod_xc.F90 b/phy/mod_xc.F90 index 286efcac..a0d032f9 100644 --- a/phy/mod_xc.F90 +++ b/phy/mod_xc.F90 @@ -92,7 +92,7 @@ module mod_xc ! line printer unit (stdout) and file unit with default values 6 and ! 12, respectively - integer :: lp=6, nfu = 12 + integer :: lp=6 ! tile dimensions and tile numbers (counting from 1), see xcspmd integer, public :: ipr, jpr, ijpr, mproc, nproc, mnproc From b8a240077c22793bdc6a820c5261f79a678e6dd8 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 14 Sep 2024 21:33:04 +0200 Subject: [PATCH 3/4] fixed cpp definitions for ARCTIC and LEVITUS2X for tnx0.5v1 --- cime_config/buildcpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/buildcpp b/cime_config/buildcpp index ec5f5bac..c4355114 100644 --- a/cime_config/buildcpp +++ b/cime_config/buildcpp @@ -89,10 +89,10 @@ def buildcpp(case): if pio_typename == "pnetcdf": blom_cppdefs = blom_cppdefs + " -DPNETCDF" - if ocn_grid in ["tnx2v1", "tnx1.5v1", "tnx1v1", "tnx1v3", "tnx1v4", "tnx0.25v1", "tnx0.25v3", "tnx0.25v4", "tnx0.125v4"]: + if ocn_grid in ["tnx2v1", "tnx1.5v1", "tnx1v1", "tnx1v3", "tnx1v4", "tnx0.5v1", "tnx0.25v1", "tnx0.25v3", "tnx0.25v4", "tnx0.125v4"]: blom_cppdefs = blom_cppdefs + " -DARCTIC" - if ocn_grid in ["gx1v5", "gx1v6", "tnx1v1", "tnx1v3", "tnx1v4", "tnx0.25v1", "tnx0.25v3", "tnx0.25v4", "tnx0.125v4"]: + if ocn_grid in ["gx1v5", "gx1v6", "tnx1v1", "tnx1v3", "tnx1v4", "tnx0.5v1", "tnx0.25v1", "tnx0.25v3", "tnx0.25v4", "tnx0.125v4"]: blom_cppdefs = blom_cppdefs + " -DLEVITUS2X" if turbclo or tracers: From e6479a031528bd8779b706368490cac433240616 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 23 Sep 2024 10:16:16 +0200 Subject: [PATCH 4/4] fixed comment --- phy/mod_xc.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phy/mod_xc.F90 b/phy/mod_xc.F90 index a0d032f9..184f71f5 100644 --- a/phy/mod_xc.F90 +++ b/phy/mod_xc.F90 @@ -90,8 +90,7 @@ module mod_xc integer, dimension (1-nbdy:idm+nbdy) :: jsu integer, dimension (1-nbdy:idm+nbdy) :: jsv - ! line printer unit (stdout) and file unit with default values 6 and - ! 12, respectively + ! line printer unit (stdout) with default values 6 integer :: lp=6 ! tile dimensions and tile numbers (counting from 1), see xcspmd