geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
166 stars 157 forks source link

[QUESTION] Where are variables like `IS_POA` are defined? #87

Closed FeiYao-Edinburgh closed 4 years ago

FeiYao-Edinburgh commented 4 years ago

Hi,

I have a small question on some codes in aerosol_mod.F, in which I have found that you defined id_POA1, id_POA2 at the top of module and then use them to define the value of IS_POA in aerosol_mod.F as IS_POA = ( id_POA1 > 0 .AND. id_POA2 > 0 ). However, I did not find any initialisation to id_POA1, id_POA2 before using them to define IS_POA. I just wonder this will give the IS_POA a value of .FALSE.?

Nevertheless, id_POA1, id_POA2 may be defined in other modules before entering subroutine aerosol_conc that I am missing? I just wonder if there is a simple rule for average users to know the values of IS_xxxx? For instance , if I have included POA1 in Advected Species in input.geos, then IS_POA will hold the value of .TRUE.?

Thanks in advance!

Yours faithfully, Fei

yantosca commented 4 years ago

You can find this out with the Unix Grep command. In your main code dir:

grep -in IS_POA */*.F*

The -i makes it ignore case and -n gives you the line number. This gives:

GeosCore/aerosol_mod.F:183:      LOGICAL            :: Is_POA
GeosCore/aerosol_mod.F:330:      LOGICAL             :: IS_POA,   IS_OPOA
GeosCore/aerosol_mod.F:387:      IS_POA     = ( id_POA1  > 0 .AND. id_POA2  > 0 )
GeosCore/aerosol_mod.F:491:         IF ( IS_POA ) THEN
GeosCore/aerosol_mod.F:662:            IF ( IS_POA ) THEN
GeosCore/aerosol_mod.F:1361:      LOGICAL             :: IS_POA, IS_OCPI
GeosCore/aerosol_mod.F:1408:      IS_POA               = ( id_POA1 > 0 .AND. id_POA2 > 0 )
GeosCore/aerosol_mod.F:1601:      IF ( IS_POA ) THEN
GeosCore/aerosol_mod.F:2861:         Is_POA     = ( id_POA1 > 0 .and. id_POA2 > 0 )
GeosCore/aerosol_mod.F:3074:            IF ( Is_POA ) THEN
GeosCore/aerosol_mod.F:3179:            IF ( Is_POA ) THEN

and then if you do:

grep -in id_POA1*/*.F*

We get:

GeosCore/aerosol_mod.F:1408:      IS_POA               = ( id_POA1 > 0 .AND. id_POA2 > 0 )
GeosCore/aerosol_mod.F:1602:         MSDENS(3) = State_Chm%SpcData(id_POA1)%Info%Density
GeosCore/aerosol_mod.F:2486:      id_POA1   = Ind_( 'POA1'   )   
GeosCore/aerosol_mod.F:2855:         id_POA1    = Ind_( 'POA1'   )

So at line 2486 of aerosol_mod.F, the id_POA1 is defined in routine INIT_AEROSOL:

      !=================================================================
      ! INIT_AEROSOL begins here!
      !=================================================================

      ! Initialize
      RC        = GC_SUCCESS
      ErrMsg    = ''
      ThisLoc   = 
     &   ' -> at Init_Aerosol (in module GeosCore/aerosol_mod.F)'

      ! Add tracer ID flags as module variables (bmy, 6/16/16)
      id_BCPI   = Ind_( 'BCPI'   )
      id_BCPO   = Ind_( 'BCPO'   )
      ... etc...
      id_POA1   = Ind_( 'POA1'   )      
      id_POA2   = Ind_( 'POA2'   )    
      id_OPOA1  = Ind_( 'OPOA1'  )   
      id_OPOA2  = Ind_( 'OPOA2'  )   
yantosca commented 4 years ago

Also, in general the id_ variables are local to each module.

FeiYao-Edinburgh commented 4 years ago

Thanks for your reply. The answer makes great sense and is also very generalised! Following your result, I have also deepened into Ind_ function defined in State_Chm_Mod and found that the function returns the index of an advected species or chemical species contained in the chemistry state object by name. Therefore, I guess my previous statement "if I have included POA1 in ADVECTED SPECIES MENU in input.geos, then id_POA1 will get an index, and thereby IS_POA will hold the value of .TRUE." is True? As an average user, I can simply associate ADVECTED SPECIES MENU defined in input.geos with id_tracers?

yantosca commented 4 years ago

The Ind function returns one of several species indices. By default it will return the overall species index but you can make it return e.g. the drydep species index by passing it Ind('POA1', 'D'). A full list of options is on the wiki: http://wiki.geos-chem.org/Species_indexing_in_GEOS-Chem#Hash-based_species_index_lookup_with_the_IND_function.

If Ind_ cannot find a value it returns -1. So testing for e.g. id_POA > 0 ensures that POA is a defined species, Then if you do IS_POA = ( id_POA > 0 ), that will return a logical true/false value.

The Advected species are always listed first. Advected species indices are the same as their overall species indices.

We have more information about species indexing in our Guide to species in GEOS-Chem on the wiki.