List of analytical header files

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
m.hadfield
Posts: 520
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

List of analytical header files

#1 Post by m.hadfield » Mon Feb 19, 2018 10:42 pm

I'm putting this in ROMS Bugs, but it's really an oddity, not a bug.

In output from a ROMS non-linear model, there is a list of directories and files near the start of the output, just before the grid and tiling information. Eg. from one of my runs:

Code: Select all

 Local Root    : /home/hadfield/ROMS/roms-trunk-mgh
 Header Dir    : /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code
 Header file   : cook_tidal_3d.h
 Analytical Dir: /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code
This is written by read_phypar.F at lines 3373-3383.

And then at the end of the run, there is a list of header files, eg:

Code: Select all

 Analytical header files used:

     ROMS/Functionals/ana_btflux.h
     /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code/ana_fsobc.h
     ROMS/Functionals/ana_initial.h
     /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code/ana_m2obc.h
     /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code/ana_m3obc.h
     ROMS/Functionals/ana_smflux.h
     ROMS/Functionals/ana_stflux.h
     /home/hadfield/mnt/kupe/nesi/nobackup/hadfield/work/cook/roms/sim35/run/tide-m2-3d/code/ana_tobc.h
This is written by close_io.F at lines 313-324.

Why wait until the end of the run to write the list of header files?

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

Re: List of analytical header files

#2 Post by arango » Tue Feb 20, 2018 5:30 am

There is a reason for it that I need to remember exactly. It is not a bug, but why does it matter? I think that it has to do with with the global attributes of output NetCDF files and the fact that the user can overwrite the location of the code header files instead of using the ones distributed by ROMS. Notice that the global attribute is updated when closing the output NetCDF. See routine netcdf_close. Also, it is a good way to modify any of the ecosystem models, say fennel.h, without touching the distributed version. If you look the test repository for the upwelling toy problem, you will notice that I provide the logic how to do this via the build script, and I have a copy of the ecosystem model there.

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

Re: List of analytical header files

#3 Post by arango » Tue Feb 20, 2018 3:54 pm

It cannot be done during initialization because the CPP include syntax <*****.h> allows to use the header files from user's directories other than ROMS/Functionals. Notice that in analytical.F, we have

Code: Select all

# ifdef SOLVE3D
#  if defined ANA_BIOLOGY && defined BIOLOGY
#   include <ana_biology.h>
#  endif
# endif
and any header file has something like:

Code: Select all

!
! Set analytical header file name used.
!
#ifdef DISTRIBUTE
      IF (Lanafile) THEN
#else
      IF (Lanafile.and.(tile.eq.0)) THEN
#endif
        ANANAME( 1)=__FILE__
      END IF
So the full path of ANANAME(:) for all the analytical header files used are only known during execution because of the __FILE__ syntax.

The header file for the ecosystem models is special. Notice that in def_info.F we have:

Code: Select all

#ifdef BIOLOGY
!
!  Biology model header file used.
!
        IF (exit_flag.eq.NoError) THEN
          DO i=1,512
            bio_file(i:i)='-'
          END DO
          status=nf90_put_att(ncid, nf90_global, 'bio_file',            &
     &                        bio_file)
          IF (FoundError(status, nf90_noerr, __LINE__,                  &
     &                   __FILE__)) THEN
            IF (Master) WRITE (stdout,20) 'bio_file', TRIM(ncname)
            exit_flag=3
            ioerror=status
          END IF
        END IF
#endif
The global attribute bio_file is set when closing the output NetCDF file in netcdf_close:

Code: Select all

#ifdef BIOLOGY
!
!  Determine updating value of biology header files global attribute.
!  This is only possible in output files. An error occurs in input
!  files open for reading only. This allows to use ROMS input files
!  with the "bio_file" attribute.
!
        IF (.not.PRESENT(Lupdate)) THEN
          my_Lupdate=.TRUE.
        ELSE
          my_Lupdate=Lupdate
        END IF
!
!  Update global attribute with the biology header files used.
!
        IF (my_Lupdate) THEN
          is=1
          status=nf90_inquire_attribute(ncid, nf90_global, 'bio_file',  &
     &                                  len = AttLen)
          IF (status.eq.nf90_noerr) THEN
            DO i=1,512
              bio_file(i:i)=' '
            END DO
            DO i=1,4
              lstr=LEN_TRIM(BIONAME(i))
              IF (lstr.gt.0) THEN
                ie=is+lstr-1
                bio_file(is:ie)=TRIM(BIONAME(i))
                is=ie+1
                bio_file(is:is)=','
                is=is+2
              END IF
            END DO
            lstr=LEN_TRIM(bio_file)-1
            IF (lstr.gt.0) THEN
              status=nf90_put_att(ncid, nf90_global, 'bio_file',        &
     &                            bio_file(1:lstr))
              IF (FoundError(status, nf90_noerr, __LINE__,              &
     &                       __FILE__ //                                &
     &                       ", netcdf_close")) THEN
                WRITE (stdout,10) 'bio_file', TRIM(my_ncname),          &
     &                            TRIM(SourceFile)
                exit_flag=3
                ioerror=status
              END IF
            END IF
          END IF
        END IF
#endif
So to report all the header files together, I decided to write its usage at the end when there are visible instead of the middle of time-stepping. So when you see weird things like that in ROMS, there is also a reason for it 8) I think that I mentioned this before in the documentation.

User avatar
m.hadfield
Posts: 520
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: List of analytical header files

#4 Post by m.hadfield » Tue Feb 20, 2018 11:08 pm

arango wrote:So to report all the header files together, I decided to write its usage at the end when there are visible instead of the middle of time-stepping. So when you see weird things like that in ROMS, there is also a reason for it 8) I think that I mentioned this before in the documentation.
:)

Post Reply