bug in def_avg.F , get_data.F, wrt_hessian.F etc

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
longmtm
Posts: 55
Joined: Tue Dec 13, 2005 7:23 pm
Location: Univ of Maryland Center for Environmental Science

bug in def_avg.F , get_data.F, wrt_hessian.F etc

#1 Unread post by longmtm »

I'm here referring to ROMS3.0 tagged version.

Here is a segment in ROMS3.0 Utility/def_avg.F
https://www.myroms.org/svn/src/tags/rom ... /def_avg.F

Code: Select all

!
!  Define surface net salt flux.
!
        IF (Hout(idTsur(isalt),ng)) THEN
          Vinfo( 1)=Vname(1,idTsur(isalt))
          WRITE (Vinfo( 2),'(a,1x,a)') Prefix,                          &
     &                                 TRIM(Vname(2,idTsur(isalt)))
          Vinfo( 3)=Vname(3,idTsur(isalt))
          Vinfo(11)='upward flux, freshening (net precipitation)'
          Vinfo(12)='downward flux, salting (net evaporation)'
          Vinfo(14)=Vname(4,idTsur(isalt))
          Vinfo(16)=Vname(1,idtime)
#   if defined WRITE_WATER && defined MASKING
          Vinfo(20)='mask_rho'
#   endif
          Vinfo(22)='coordinates'
          Aval(5)=REAL(Iinfo(1,idTsur(itemp),ng),r8)
          status=def_var(ncAVGid(ng),avgVid(idTsur(isalt),ng),NF_FOUT,  &
     &                   nvd3,t2dgrd,Aval,Vinfo,ncname)
        END IF
The upper section is solely used for defining a new variable in history output. So it should not
have "idTsur(itemp)" in it. Hence the 4th to the last line should be:

Code: Select all

   Aval(5)=REAL(Iinfo(1,idTsur(isalt),ng),r8)
Another thing is in ROMS/Nonlinear/get_data.F
https://www.myroms.org/svn/src/tags/rom ... get_data.F
where

Code: Select all

  #  ifndef ANA_SPFLUX
                !
                !-----------------------------------------------------------------------
                !  Passive tracers surface fluxes.
                !-----------------------------------------------------------------------
                !
                      DO i=NAT+1,NT(ng)
                        CALL get_2dfld (ng, iNLM, idTsur(i), ncFRCid(idTsur(i),ng),     &
                     &                  nFfiles(ng), FRCname(1,ng), update(1),          &
                     &                  LBi, UBi, LBj, UBj, 2, 1,                       &
                #   ifdef MASKING
                     &                  GRID(ng) % rmask(LBi,LBj),                      &
                #   endif
                     &                  FORCES(ng) % stflxG(LBi,LBj,1,i))
                      END DO
                #  endif
                #  ifndef ANA_BPFLUX
                !
                !-----------------------------------------------------------------------
                !  Passive tracers bottom fluxes.
                !-----------------------------------------------------------------------
                !
                      DO i=NAT+1,NT(ng)
                        CALL get_2dfld (ng, iNLM, idTbot(i), ncFRCid(idTbot(i),ng),     &
                     &                  nFfiles(ng), FRCname(1,ng), update(1),          &
                     &                  LBi, UBi, LBj, UBj, 2, 1,                       &
                #   ifdef MASKING
                     &                  GRID(ng) % rmask(LBi,LBj),                      &
                #   endif
                     &                  FORCES(ng) % btflxG(LBi,LBj,1,i))
                      END DO
                #  endif
            # endif
refers to all passive surface and bottom tracer fluxes from forcing inputs, however, idTsur(i) and idTbot(i) are not well defined in mod_ncparam.F except for idTsur(itemp) and idTsur(isalt):
https://www.myroms.org/svn/src/tags/rom ... _ncparam.F

Code: Select all

   CASE ('idTsur(itemp)')
                idTsur(itemp)=varid
              CASE ('iddQdT')
                iddQdT=varid
              CASE ('idsfwf')
                idsfwf=varid
              CASE ('idTsur(isalt)')
                idTsur(isalt)=varid
              CASE ('idTbot(itemp)')
                idTbot(itemp)=varid
              CASE ('idTbot(isalt)')
in Utility/wrt_hessian.F

Code: Select all

#  ifdef ADJUST_STFLUX
!
!  Write out surface tracer fluxes.
!
      DO itrc=1,NT(ng)
        scale=1.0_r8
        gtype=gfactor*r2dvar
        status=nf_fwrite2d(ng, iADM, ncHSSid(ng),                       &
     &                     hssVid(idTsur(itrc),ng),                     &
     &                     tHSSindx(ng), gtype,                         &
     &                     LBi, UBi, LBj, UBj, scale,                   &
#   ifdef MASKING
     &                     GRID(ng) % rmask(LBi,LBj),                   &
#   endif
     &                     FORCES(ng) % ad_stflx(LBi,LBj,itrc))
        IF (status.ne.nf_noerr) THEN
          IF (Master) THEN
            WRITE (stdout,10) TRIM(Vname(1,idTsur(itrc))),              &
     &                        tHSSindx(ng)
          END IF
          exit_flag=3
          ioerror=status
          RETURN
        END IF
      END DO
#  endif
also refers to all tracer surface fluxes, yet only idTsur(isalt) and idTsur(itemp) are really
assigned in mod_ncparam.F

Same issue in def_hessian.F

Code: Select all

#  ifdef ADJUST_STFLUX
!
!  Define surface tracer fluxes.
!
        DO itrc=1,NT(ng)
          Vinfo( 1)=Vname(1,idTsur(itrc))
          WRITE (Vinfo( 2),40) TRIM(Vname(2,idTsur(itrc)))
          Vinfo( 3)='nondimensional'
          Vinfo(14)=Vname(4,idTsur(itrc))
          Vinfo(16)=Vname(1,idtime)
          status=def_var(ncHSSid(ng),hssVid(idTsur(itrc),ng),           &
     &                   NF_FOUT,nvd3,t2dgrd,Aval,Vinfo,ncname)
        END DO
#  endif
# endif



User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: bug in def_avg.F , get_data.F, wrt_hessian.F etc

#2 Unread post by arango »

First, tagged versions of ROMS are never corrected. They are kept for historical reasons and evolution of the code. ROMS 3.0 is a very old version released on April 2007. Many critical and important bugs have been corrected since them and the things that you mention above are less worrysome. You should use the latest version of the code :!:

The only version of ROMS code that evolves and get corrected is the :arrow: trunk. This is not the first time that this is happening. There are users out there still using ROMS 2.2. This is absurd. Perhaps, we should reconsider our policy and remove access to all tagged versions except the last one. Say, :arrow: roms-3.3.

Now, the things that you describe above are just typos and not bugs. If you just study the code, you will find out that:

Code: Select all

        Iinfo(1,idTsur(itemp),ng)=Iinfo(1,idTsur(isalt),ng)=r2dvar=2
That is,

Code: Select all

        Iinfo(1,idTsur(:),ng)=r2dvar     ! for all tracers
always :!: since this is a 2D variable at RHO-points. You need to do your homework :shock:

I have no idea why you are using the Hessian files. These are only used in the adjoint-based algorithms like IS4DVAR preconditioning. If this is the case, you need to use the latest version of ROMS. The adjoint-based algorithms have evolved substantially since them.

Now, the only surface tracer flux that we know are those for temperature (net heat flux) and salinity (net freshwater flux or net salt flux below the ice). The surface salinity flux is the most unknown quantity in the ocean and one big headache in ocean modeling. Perhaps, we can get a better insight to this flux from the salinity satellite in the near future (although at a very coarse resolution). Other passive surface fluxes are less known, so it is a good approximation to set them to zero, using ANA_SPFLUX. There is not such thing as surface flux of phytoplankton, zooplankton, dyes, and so on. The bottom flux of tracer should be zero too, unless that you have hydrothermal vents in you domain and they are affecting the bottom circulation. This is just a matter of metadata. The newer version of ROMS allows the user to customize all this input metadata for ecosystem and sediment model. In this way you can customize your mod_ncparam.F.

So my recommendation to you is to UPDATE ...

longmtm
Posts: 55
Joined: Tue Dec 13, 2005 7:23 pm
Location: Univ of Maryland Center for Environmental Science

Re: bug in def_avg.F , get_data.F, wrt_hessian.F etc

#3 Unread post by longmtm »

Other passive surface fluxes are less known, so it is a good approximation to set them to zero, using ANA_SPFLUX. There is not such thing as surface flux of phytoplankton, zooplankton, dyes, and so on. The bottom flux of tracer should be zero too, unless that you have hydrothermal vents in you domain and they are affecting the bottom circulation. This is just a matter of metadata. The newer version of ROMS allows the user to customize all this input metadata for ecosystem and sediment model. In this way you can customize your mod_ncparam.F.

First of all, thanks a lot for suggesting that we should adapt to the newest version. The reason we are still using the legacy code is we have a working system with some modifications and don't want to break it. I'm sure there are new bugs introduced from ROMS3.0 to ROMS3.3 or the current trunk. We'd prefer wait a bit until the newer versions have been tried out extensively and have bugs reported. Hence I don't suggest you guys remove access to tagged versions.

That being said, I'm interested in specifying passive tracer fluxes from the surface (especially NO3, NH4, and PO4 atmospheric deposition) for the ecological model and we want to get
away from ANA_SPFLUX for some flexibility.

Thanks again,

Wen

User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: bug in def_avg.F , get_data.F, wrt_hessian.F etc

#4 Unread post by arango »

The current version is quite stable and has been tested extensively. However, ROMS will continue evolving. We cannot force users to use the appropriate version of ROMS. We really don't have the time to answering questions about problems that have been fixed in newer versions.

Actually, the new design of the ecosystem models will allow you, very easily, to add those surface fluxes in the appropriated include file for mod_ncparam.F.

longmtm
Posts: 55
Joined: Tue Dec 13, 2005 7:23 pm
Location: Univ of Maryland Center for Environmental Science

Re: bug in def_avg.F , get_data.F, wrt_hessian.F etc

#5 Unread post by longmtm »

Good to know the new ecological model has more flexibility and the ROMS3.3 or later is already stable.

We will move forward to keep up with you guys.

Wen

Post Reply