2D momentum boundary conditions missing in running log

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
FengZhou
Posts: 52
Joined: Wed Apr 07, 2004 10:48 pm
Location: 2nd Institute of Oceanography,SOA

2D momentum boundary conditions missing in running log

#1 Unread post by FengZhou »

Hi,

Could anyone tell me why 2d momentum boundary conditions donot work. I do define :

#define EAST_M2RADIATION
#define EAST_M2NUDGING

in cppdefs.h, but they don't show up in running log file. While if I defined EAST_M2GRADIENT, it shows up its working.

Thanks in andvance!

feng

User avatar
kate
Posts: 4088
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#2 Unread post by kate »

The place to look is in checkdefs.F. Search on EAST_M2RADIATION to see how it gets reported (or not). It is in my version...

FengZhou
Posts: 52
Joined: Wed Apr 07, 2004 10:48 pm
Location: 2nd Institute of Oceanography,SOA

#3 Unread post by FengZhou »

Thanks, Kate!

you are right. The EAST_M2RADIATION is missing in check_defs.F.

User avatar
shchepet
Posts: 188
Joined: Fri Nov 14, 2003 4:57 pm

There is a permanent solution to this problem

#4 Unread post by shchepet »

There is a permanent solution to this problem practiced in UCLA and Agrif codes for the last 7+ years: create a mechanism for automatic tracking of the status of each CPP switch in "cppdefs.h" by automatically generating an analog of Rutgers "checkdefs.F" (known as "check_switches1.F" in UCLA and Agrif code).

That takes care of the situation that if several years from now somebody introduces a brand new CPP switch to activate a brand new algorithm or option and defines and undefines that switch in "cppdefs.h", and (as it happens all the time) DOES NOT BOTHER to create a corresponding entry in "checkdefs.F", the status of that switch will be AUTOMATICALLY reflected in both log file and as a signature in netcdf files created by the roms code.

This can be adapted for Rutgers codes as well.

To see how it works, get "cppcheck.F" from

Code: Select all

http://www.atmos.ucla.edu/~alex/ROMS/cppcheck.F
and compile it using fortran compiler you normally use to compile the rest of your ROMS. The result of this compilation should be named as "cppcheck".

Then go to directory where file "cppdefs.h" is located and execute "cppcheck." (no argument needed, just type ./cppcheck). That command gives some output on the screen, which is purely for information, and it also creates file "check_switches1.F", which is a fortran code. Study this file, and you will see that an automatically generated analog of your "checkdefs.F", which is guaranteed to be consistent with current status of "cppdefs.h".

The actual mechanism for self-documentation works as follows:

your Makefile should contain the following nests with proper dependencies

Code: Select all

cppcheck: cppcheck.o
        $(LDR) $(FFLAGS) $(LDFLAGS) -o cppcheck cppcheck.o

check_switches1.F: cppcheck cppdefs.h
        ./cppcheck
with [Tab] character in front of $(LDR) and /cppcheck. And, of course, check_switches1.F is included into source code list and the subroutine is actually called somewhere in the beginning (in UCLA/Agrif is is called from "init_scalars" along with other sanity checking routines).

The rationale for the dependencies above is as follows: whenever you touch cppdefs.h, check_switches1.F is regenerated automatically, and because it is in source list, it will be compiled in into roms executable. Upon execution "check_switches1" does two things
  1. it writes on the screen the name of each active CPP switch (so your log file reflects what was defined and what was not, and
  2. it generates string called "cpps" which consists record of activated CPP-switches. This string should be written as a global attribute into all netcdf files created by your roms.
Of course, the whole thing is designed to work in UCLA/Agrif conventions and environment, so you must do some adaptation to make it compatible with Rutgers code. The adaptations must be done in "cppcheck.F" and not in "check_switches1.F", and it is relatively straightforward because "check_switches1" needs to know very little about your code:

string "cpps" of length "max_opt_size" is declared in file "strings.h" as follows

Code: Select all

integer max_opt_size
parameter (max_opt_size=2048)
character*(max_opt_size) cpps, srcs, kwds
common /strings/ cpps, srcs, kwds
and must be visible by the rest of the code.

"MPI_master_only" is a CPP-macro defined in "globaldefs.h" as

Code: Select all

#ifdef MPI
# define MPI_master_only if (mynode.eq.0)
#else
# define MPI_master_only
#endif
which basically restricts writing to the string to MPI-node 0, if you run MPI code, and is nothing in OpenMP mode. (#ifdef MPI is analogous to Hernan's #ifdef DISTRIBUTE)

Post Reply