DOI-USGS / COAWST

COAWST modeling system git repository
Other
100 stars 48 forks source link

ROMS-WRF currents coupling - compiling failure #245

Open kyle-hinson opened 2 months ago

kyle-hinson commented 2 months ago

Hi all. I'm trying to compile a ROMS-WRF setup (no waves) in COAWST that includes the effects of ROMS surface currents on WRF surface winds. I've successfully compiled a 'base case' ROMS-WRF setup, and have tried to modify the code to exchange information about surface currents in Master/roms_wrf_mct.h, WRF/frame/atm_coupler.F, and WRF/phys/module_sf_mynn.F (attached files include edits following work done by Shi and Bourassa, 2019).

coawst_modifications.zip

I'm not sure exactly what additional modifications to the code I might be missing, below are a couple snippets of output from my attempt to compile. Here it seems to run into some major issues, but continues compiling:

I/projects/COAWST/Build  -I/projects/COAWST/Lib/MCT/include -real-size `expr 8 \* 4` -i4  module_nesting.f90
atm_coupler.f90(1197): error #6460: This is not a component name that is defined in the encompassing structure.   [UCURRENT]
          grid%ucurrent(i,j)=AA(ij)*Amask(ij)
---------------^
atm_coupler.f90(1197): error #6158: The structure-name is invalid or is missing.   [GRID]
          grid%ucurrent(i,j)=AA(ij)*Amask(ij)
----------^
atm_coupler.f90(1197): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [GRID]
          grid%ucurrent(i,j)=AA(ij)*Amask(ij)
----------^
atm_coupler.f90(1207): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [GRID]
          grid%vcurrent(i,j)=AA(ij)*Amask(ij)
----------^
 
real        0m0.519s
user       0m0.249s
sys          0m0.500s
rm -f module_cpl_oasis3.o
compilation aborted for atm_coupler.f90 (code 1)
 
real        0m0.550s
user       0m0.170s
sys          0m0.519s
make[3]: [../configure.wrf:395: atm_coupler.o] Error 1 (ignored)

And below is where it finally finishes attempting to compile and fails.

cd ./Build; /nopt/nrel/apps/mpi/08-23/spack/opt/spack/linux-rhel8-icelake/intel-2021.10.0/intel-oneapi-mpi-2021.10.0-7iolquprezbcmmeapg7rlcwfsd4r3rc7/mpi/2021.10.0/bin/mpif90 -c -fp-model precise -ip -O3 -traceback -f90=ifort -I/projects/COAWST/Lib/MCT/include -I/projects/kehinson/COAWST//WRF/main -I/projects/COAWST//WRF/external/esmf_time_f90 -I/projects/COAWST//WRF/frame -I/projects/COAWST//WRF/share master.f90
master.f90(22): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MODULE_WRF_TOP]
      USE module_wrf_top, ONLY : wrf_init
----------^
master.f90(22): error #6580: Name in only-list does not exist or is not accessible.   [WRF_INIT]
      USE module_wrf_top, ONLY : wrf_init
---------------------------------^
master.f90(23): error #6580: Name in only-list does not exist or is not accessible.   [WRF_RUN]
      USE module_wrf_top, ONLY : wrf_run
---------------------------------^
master.f90(24): error #6580: Name in only-list does not exist or is not accessible.   [WRF_FINALIZE]
      USE module_wrf_top, ONLY : wrf_finalize
---------------------------------^
compilation aborted for master.f90 (code 1)
make: *** [Master/Module.mk:25: Build/master.o] Error 1

I looked around a bit at Hernan's recent test case to see what other modifications were made to the code but wasn't sure if this has been fully integrated into COAWST already. Any pointers as to where else I can define the new 'ucurrent' and 'vcurrent' variables to make sure that they're exchanged with the atmospheric coupler or MCT exchange would be much appreciated, thanks for any help.

jcwarner-usgs commented 2 months ago

you need to make changes in Master/mct_roms_wrf.h and in WRF/frame/atm_coupler.F Look at SST as an example. You might need to add something into WRF/Registry. not sure. WRF will continue to build after an error. ROMS will stop if it gets a error. because WRF uses make -? (i forget the command, -k or something). Is grid%ucurrent already a WRF variable? i think you want to hook into grid%uoce and grid%voce in wrf.

kyle-hinson commented 2 months ago

Thanks for the feedback! I had already made changes to Master/mct_roms_wrf.h and WRF/frame/atm_coupler.F, but it looks like once I changed the variable names from 'UCURRENT' and 'VCURRENT' to 'UOCE' and 'VOCE' that fixed many of the problems and I was able to compile successfully.

I think that the main issue that I'm having now is related to my modifications to WRF/phys/module_sf_mynn.F so that these currents actually interact with surface-level winds. I'm attempting to add the surface currents to variables like U10 and V10 (example modifications below).

 !-----------------------------------------------------
   !COMPUTE 10 M WNDS
   !-----------------------------------------------------
   ! If the lowest model level is close to 10-m, use it
   ! instead of the flux-based diagnostic formula.
   if (ZA(i) .le. 7.0) then
      ! high vertical resolution
      if(ZA2(i) .gt. 7.0 .and. ZA2(i) .lt. 13.0) then
         !use 2nd model level
         U10(I)=U1D2(I)+UOCE(I)
         V10(I)=V1D2(I)+VOCE(I)
      else
         U10(I)=(U1D(I)+UOCE(I))*log(10./ZNTstoch(I))/log(ZA(I)/ZNTstoch(I))
         V10(I)=(V1D(I)+VOCE(I))*log(10./ZNTstoch(I))/log(ZA(I)/ZNTstoch(I))
      endif
   elseif(ZA(i) .gt. 7.0 .and. ZA(i) .lt. 13.0) then
      !moderate vertical resolution
      !U10(I)=U1D(I)*PSIX10/PSIX
      !V10(I)=V1D(I)*PSIX10/PSIX
      !use neutral-log:
      U10(I)=(U1D(I)+UOCE(I))*log(10./ZNTstoch(I))/log(ZA(I)/ZNTstoch(I))
      V10(I)=(V1D(I)+VOCE(I))*log(10./ZNTstoch(I))/log(ZA(I)/ZNTstoch(I))
   else
      ! very coarse vertical resolution
      U10(I)=(U1D(I)+UOCE(I))*PSIX10/PSIX
      V10(I)=(V1D(I)+VOCE(I))*PSIX10/PSIX
   endif

However, the error that I'm getting seems to be related to an inability to define this variable in the SFCLAY1D_mynn submodules. Is this what has to be modified in the WRF registry (maybe 'WRF/Registry/Registry'?) file that you mentioned?

module_sf_mynn.f90(738): error #6420: This array name is invalid in this context.   [UOCE]
       REAL, DIMENSION( ims:ime ), INTENT(IN) :: UOCE, VOCE
-------------------------------------------------^
module_sf_mynn.f90(738): error #6420: This array name is invalid in this context.   [VOCE]
       REAL, DIMENSION( ims:ime ), INTENT(IN) :: UOCE, VOCE
-------------------------------------------------------^
module_sf_mynn.f90(612): error #6784: The number of actual arguments cannot be greater than the number of dummy arguments.   [SFCLAY1D_MYNN]
        CALL SFCLAY1D_mynn(                                        &
-------------^
module_sf_mynn.f90(631): error #6633: The type of the actual argument differs from the type of the dummy argument.   [UOCE]
                UOCE(ims,j), VOCE(ims,j),                  &
----------------^
module_sf_mynn.f90(631): error #6633: The type of the actual argument differs from the type of the dummy argument.   [VOCE]
                UOCE(ims,j), VOCE(ims,j),                  &
-----------------------------^
module_sf_mynn.f90(635): error #6633: The type of the actual argument differs from the type of the dummy argument.   [ISFTCFLX]
                ,isftcflx,iz0tlnd,                                 &
-----------------^
module_sf_mynn.f90(635): error #6633: The type of the actual argument differs from the type of the dummy argument.   [IZ0TLND]
                ,isftcflx,iz0tlnd,                                 &
--------------------------^
module_sf_mynn.f90(635): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [ISFTCFLX]
                ,isftcflx,iz0tlnd,                                 &
-----------------^
module_sf_mynn.f90(635): error #6780: A dummy argument with the INTENT(IN) attribute shall not be defined nor become undefined.   [IZ0TLND]
                ,isftcflx,iz0tlnd,                                 &
--------------------------^
module_sf_mynn.f90(612): error #8284: If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.   [USTM]
        CALL SFCLAY1D_mynn(                                        &
-------------^
module_sf_mynn.f90(612): error #8284: If the actual argument is scalar, the dummy argument shall be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.   [CK]
        CALL SFCLAY1D_mynn(                                        &
-------------^
compilation aborted for module_sf_mynn.f90 (code 1)
jcwarner-usgs commented 2 months ago

you might need to add the UOCS and VOCE to the routine that calls sfclay. you will need to go backwards in the code.

kyle-hinson commented 2 months ago

Thanks for the suggestion. This is what I had previously added into the sfclay routine, trying to follow other variables like HWAVE, LWAVEP, and PWAVE.

!-------------------------------------------------------------------
   SUBROUTINE SFCLAY_mynn(                                  &
              U3D,V3D,T3D,QV3D,P3D,dz8w,                    &
              CP,G,ROVCP,R,XLV,PSFCPA,CHS,CHS2,CQS2,CPM,    &
              ZNT,UST,PBLH,MAVAIL,ZOL,MOL,REGIME,PSIM,PSIH, &
              XLAND,HFX,QFX,LH,TSK,FLHC,FLQC,QGH,QSFC,RMOL, &
              U10,V10,TH2,T2,Q2,SNOWH,                      &
              GZ1OZ0,WSPD,BR,ISFFLX,DX,                     &
              SVP1,SVP2,SVP3,SVPT0,EP1,EP2,                 &
              KARMAN,itimestep,ch,th3d,pi3d,qc3d,rho3d,qcg, &
              spp_pbl,pattern_spp_pbl,                      &
#if defined SWAN_COUPLING || defined WW3_COUPLING
                     HWAVE, LWAVEP, PWAVE,                  &
#endif
!======ADDED SURFACE CURRENTS======================
#if defined ROMS_COUPLING
                     UOCE, VOCE,                    &
#endif
!==================================================
              ids,ide, jds,jde, kds,kde,                    &
              ims,ime, jms,jme, kms,kme,                    &
              its,ite, jts,jte, kts,kte,                    &
              ustm,ck,cka,cd,cda,isftcflx,iz0tlnd           )
!-------------------------------------------------------------------

I've also already added these variables in the additional SFCLAY_1D_MYNN subroutine. Are you saying that this function is defined somewhere else in WRF as well? Or am I misunderstanding where else these variables need to be declared?

kyle-hinson commented 1 month ago

Was able to track down some of my issues that I previously ran into (missing comma threw a syntax error), but it looks as if the new error is pointing me to WRF/phys/module_surface_driver.F as the new source of my issues. UOCE and VOCE are both already defined in this file, and I'm not entirely sure what to make of the error below.

module_surface_driver.f90(5146): error #6404: This name does not have a type, and must have an explicit type.   [UOCE]
          UOCE, VOCE,                                         &
----------^
module_surface_driver.f90(5146): error #6404: This name does not have a type, and must have an explicit type.   [VOCE]
          UOCE, VOCE,                                         &
----------------^
compilation aborted for module_surface_driver.f90 (code 1)

Do I need to create a new set of variables like SST_INPUT for UOCE and VOCE while changing the definitions from

   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(OUT)::   UOCE
   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(OUT)::   VOCE

to something more like what I have below so that they can have similar cpl_rcv functions as SST later in module_surface_driver.F? I tried compiling with this code setup without any luck so far.

   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT)::   UOCE
   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(INOUT)::   VOCE
   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN   )::   UOCE_INPUT
   REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN   )::   VOCE_INPUT
jcwarner-usgs commented 1 month ago

i dont think you should make new vars. there is just something off with the current uoce and voce. can you post your moduels_surface_driver.F

kyle-hinson commented 1 month ago

Sure thing, attached here. Have also included my module_sf_mynn.F if that's useful. phys_modules.zip