Changeset 4235 for dynamico_lmdz


Ignore:
Timestamp:
Jan 21, 2020, 12:54:37 AM (5 years ago)
Author:
dubos
Message:

simple_physics : DYNAMICO driver

Location:
dynamico_lmdz/simple_physics
Files:
1 added
10 edited
2 moved

Legend:

Unmodified
Added
Removed
  • dynamico_lmdz/simple_physics/bash/beautify.sh

    r4233 r4235  
    11#!/bin/bash
     2
     3# NOTE : sed -i seems to work differently on GNU and OSX systems
     4# a temporary file is used instead
     5
     6TMP=$(mktemp)
     7
    28for x in $* ; do
    39    # indent source file using emacs in batch mode
     
    511    emacs -batch $x --eval '(f90-mode)' --eval '(indent-region (point-min) (point-max) nil)' --eval '(delete-trailing-whitespace)' -f save-buffer 2>/dev/null
    612    # remove blank lines at end of file
    7     sed -i '' -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $x
     13    sed  -e :a -e '/^\n*$/{$d;N;};/\n$/ba' $x  > $TMP
     14    cp -f $TMP $x
    815done
     16
     17rm -f $TMP
  • dynamico_lmdz/simple_physics/bash/concatenate_all_code.sh

    r4234 r4235  
    44
    55for src in $* ; do
    6     awk "{ print \"$src \" \$0; }" physics/${src}.F90
     6    awk "{ print \"$src \" NR \" \" \$0; }" physics/${src}.F90
    77done
  • dynamico_lmdz/simple_physics/bash/makedeps.sh

    r4234 r4235  
    33# input file $1 is output of bash/concatenate_all_code.sh, see phyparam/Makefile
    44
    5 function find_use()
     5function print_deps()
    66{
    7     grep '\bUSE\b' | grep -i -v '\bEND\b' | tr ',' ' ' | awk '{print "obj/" $1 ".o : " "obj/" $3 ".o" }'
     7    tr ',' ' ' | awk '{print "obj/" $1 ".o : " "obj/" $4 ".o" }'
    88}
    99
    10 cat $1 | find_use
     10grep '\bUSE\b' $1 | grep -i -v 'INTRINSIC' | grep -i -v '\bEND\b' | print_deps
  • dynamico_lmdz/simple_physics/phyparam/DYNAMICO/icosa_phyparam_mod.F90

    r4231 r4235  
    11MODULE icosa_phyparam_mod
     2#include "use_logging.h"
     3
     4! FCM gets confused when external modules are USEd at module level
     5! => USE statements to DYNAMICO modules go into subroutines
     6
    27  IMPLICIT NONE
     8  PRIVATE
    39  SAVE
     10
     11  LOGICAL :: firstcall = .TRUE.
     12  LOGICAL, PARAMETER :: lastcall = .FALSE.
     13
     14  REAL, PARAMETER :: oneday = 86400. ! hard-coded                                                                                                                                                         
     15  INTEGER, PARAMETER :: log_unit = 15
     16
     17  PUBLIC :: init_physics, physics
    418
    519  CONTAINS
     
    721    SUBROUTINE init_physics
    822      ! DYNAMICO
    9       USE mpipara,   ONLY : is_mpi_master
    10       USE icosa,     ONLY : llm, g, radius, cpp, kappa
    11       USE time_mod,  ONLY : dt, itau_physics
     23      USE mpipara,  ONLY : is_mpi_master
     24      USE icosa,    ONLY : llm
     25
     26      USE icosa,     ONLY : g, radius, cpp, kappa
    1227      USE getin_mod, ONLY : getin
    13       USE physics_interface_mod
     28      USE physics_interface_mod, ONLY : inout => physics_inout
    1429      ! phyparam
     30      USE logging, ONLY : flush_plugin, dbtag, max_log_level
     31      USE read_param_mod
    1532      USE comgeomfi
    1633      USE iniphyparam_mod
    1734      INTEGER, PARAMETER :: dayref=0
    18       INTEGER :: ngrid
     35      CHARACTER(10) :: physics_log_level
     36      INTEGER :: ngrid, lev
     37      REAL    :: timestep
    1938      REAL    :: unjours ! solar day in seconds
    2039
    21       IF(is_mpi_master) WRITE(*,*) 'phyparam/init_physics called'
    22      
    23       ngrid = physics_inout%ngrid
     40      flush_plugin => flush_log_
     41
     42      physics_log_level='INF'
     43      CALL getin('physics_log_level', physics_log_level)
     44      DO lev=1, SIZE(dbtag)
     45         IF(dbtag(lev)==TRIM(physics_log_level)) THEN
     46            max_log_level = lev
     47            EXIT
     48         END IF
     49      END DO
     50
     51      read_paramr_plugin => read_paramr
     52      read_parami_plugin => read_parami
     53      read_paramb_plugin => read_paramb
     54
     55      WRITELOG(*,*) 'init_physics called'
     56      WRITELOG(*,*) 'physics log level set to ', dbtag(max_log_level)
     57      LOG_INFO('phyparam')
     58
     59      ngrid = inout%ngrid
     60      timestep = inout%dt_phys
     61
    2462      unjours = 86400.
    2563      CALL getin('unjours', unjours)
    2664
    27       CALL init_comgeomfi(ngrid, llm, &
    28            &              physics_inout%lon, physics_inout%lat)
     65      CALL init_comgeomfi(ngrid, llm, inout%lon, inout%lat)
    2966      CALL iniphyparam(ngrid, llm,                &
    30            &           unjours, dayref, dt*itau_physics, &
     67           &           unjours, dayref, timestep, &
    3168           &           radius, g, cpp*kappa, cpp)
    3269
     
    3471
    3572    SUBROUTINE physics
    36       USE mpipara, ONLY : is_mpi_master
    37       IF(is_mpi_master) PRINT *, 'phyparam/physics called'
     73      USE mpipara,  ONLY : is_mpi_master
     74      USE icosa,    ONLY : llm
     75      USE physics_interface_mod, ONLY : inout => physics_inout
     76      USE phyparam_mod
     77      USE error_mod
     78      REAL :: dps(inout%ngrid), play(inout%ngrid, llm), pphi(inout%ngrid, llm)
     79      REAL :: timestep, time, jourvrai, gmtime
     80      INTEGER :: l
     81      IF(is_mpi_master) WRITE(log_unit,*) 'phyparam/physics called', SHAPE(inout%p), SHAPE(inout%pk)     
     82
     83      timestep = inout%dt_phys
     84      time = timestep * inout%it
     85      gmtime = time/oneday
     86      jourvrai = FLOOR(gmtime)
     87      gmtime   = gmtime - jourvrai
     88
     89      ! compute pressure and geopotential at full levels
     90      CALL compute_play(inout%ngrid, llm, inout%p, play)
     91      CALL compute_play(inout%ngrid, llm, inout%geopot, pphi)
     92
     93      ! substract surface geopotential
     94      DO l=1,llm
     95         pphi(:,l) = pphi(:,l) - inout%geopot(:,1)
     96      END DO
     97
     98      IF(is_mpi_master) PRINT *, 'phyparam phi :', pphi(inout%ngrid/2+1, :)
     99
     100      CALL check_NaN('physics', 'ulon', inout%ulon)
     101      CALL check_NaN('physics', 'ulat', inout%ulat)
     102      CALL check_NaN('physics', 'temp', inout%temp)
     103
     104      ! go
     105      CALL phyparam(inout%ngrid,llm,                       &
     106           &        firstcall,lastcall,                    &
     107           &        jourvrai, gmtime, timestep,            &
     108           &        inout%p, play, pphi,                   &
     109           &        inout%ulon,  inout%ulat,  inout%temp,  &
     110           &        inout%dulon, inout%dulat, inout%dtemp, dps)
     111
     112      IF(is_mpi_master) PRINT *, 'phyparam dT :', inout%dtemp(inout%ngrid/2+1, :)
     113
     114      CALL check_NaN('physics', 'dulon', inout%dulon)
     115      CALL check_NaN('physics', 'dulat', inout%dulat)
     116      CALL check_NaN('physics', 'dtemp', inout%dtemp)
     117
     118      firstcall = .FALSE.
    38119    END SUBROUTINE physics
    39120
     121    SUBROUTINE compute_play(ngrid, llm, plev, play)
     122      INTEGER, INTENT(IN) :: ngrid, llm
     123      REAL, INTENT(IN)    :: plev(ngrid, llm+1) ! pressure at interfaces (half-levels)
     124      REAL, INTENT(OUT)   :: play(ngrid, llm)   ! pressure in layers (full levels)
     125      INTEGER :: ij, l
     126      DO l = 1,llm
     127         DO ij = 1,ngrid
     128            play(ij,l) = .5*(plev(ij,l)+plev(ij,l+1))
     129         END DO
     130      END DO
     131    END SUBROUTINE compute_play
     132
     133!------------------------------------------------------------------------------------
     134!------------------------------- Infrastructure plugins -----------------------------
     135
     136!--------------------------------------- Logging ------------------------------------
     137
     138    SUBROUTINE flush_log_(lev, tag, buf)
     139      USE mpipara, ONLY : is_mpi_master
     140      USE logging, ONLY : dbtag
     141      INTEGER, INTENT(IN) :: lev
     142      CHARACTER(*), INTENT(IN) :: tag, buf(:)
     143      CHARACTER(100) :: prefix
     144      INTEGER :: i
     145
     146      IF(is_mpi_master) THEN
     147         WRITE(prefix,*) '[', dbtag(lev), ' ', tag, ']'
     148         DO i=1, SIZE(buf)
     149            WRITE(log_unit,*) TRIM(prefix), TRIM(buf(i))
     150         END DO
     151         WRITE(log_unit, *) ''
     152      END IF
     153    END SUBROUTINE flush_log_
     154
     155!--------------------------------------- read_param ------------------------------------
     156
     157    SUBROUTINE read_paramr(name, defval, val, comment)
     158      USE getin_mod, ONLY : getin
     159      CHARACTER(*), INTENT(IN) :: name, comment
     160      REAL, INTENT(IN)         :: defval
     161      REAL, INTENT(OUT)        :: val
     162      val = defval
     163      CALL getin(name, val)
     164    END SUBROUTINE read_paramr
     165
     166    SUBROUTINE read_parami(name, defval, val, comment)
     167      USE getin_mod, ONLY : getin
     168      CHARACTER(*), INTENT(IN) :: name, comment
     169      INTEGER, INTENT(IN)      :: defval
     170      INTEGER, INTENT(OUT)     :: val
     171      val = defval
     172      CALL getin(name, val)
     173    END SUBROUTINE read_parami
     174   
     175    SUBROUTINE read_paramb(name, defval, val, comment)
     176      USE getin_mod, ONLY : getin
     177      CHARACTER(*), INTENT(IN) :: name, comment
     178      LOGICAL, INTENT(IN)      :: defval
     179      LOGICAL, INTENT(OUT)     :: val
     180      val = defval
     181      CALL getin(name, val)
     182    END SUBROUTINE read_paramb
     183
    40184END MODULE icosa_phyparam_mod
  • dynamico_lmdz/simple_physics/phyparam/Makefile

    r4234 r4235  
    1111F90FLAGS ?= -ffree-line-length-none
    1212
    13 VPATH = obj
    1413NAMES = $(basename $(notdir $(wildcard physics/*.F90)))
    1514OBJECTS = $(addprefix obj/, $(addsuffix .o, $(NAMES)))
     
    1817
    1918obj :
     19        @rm -rf obj include lib xml tmp *~ */*~
    2020        @mkdir obj include lib xml tmp
    2121
    22 deps :
     22clean :
     23        @rm -rf obj include lib xml tmp *~ */*~
     24        @mkdir obj include lib xml tmp
    2325        @../bash/concatenate_all_code.sh $(NAMES) > tmp/all_code
    2426        @../bash/makedeps.sh tmp/all_code >  Makefile.inc
    25 
    26 clean : deps
    27         rm -rf obj include lib xml tmp *~ */*~
    2827
    2928nice:
     
    4140        @$(FFRONT) -M tmp tmp/$(SRC).f90 > xml/$(SRC).xml
    4241
     42# dependencies between modules
     43
     44$(OBJECTS) : obj/logging.o
    4345-include Makefile.inc
  • dynamico_lmdz/simple_physics/phyparam/physics/callkeys.F90

    r4229 r4235  
    33  SAVE
    44
    5   LOGICAL callrad,calldifv,calladj,callcond,callsoil,season,diurnal,lverbose
    6   INTEGER iradia
    7   REAL period_sort
     5  LOGICAL ::  callrad, calldifv, calladj, callsoil, season, diurnal, lverbose
     6  INTEGER :: iradia
     7  REAL :: period_sort
    88
    99END MODULE callkeys
  • dynamico_lmdz/simple_physics/phyparam/physics/iniphyparam_mod.F90

    r4230 r4235  
    5454    CALL read_param('coefir',.08      ,coefir,'coefir')
    5555
    56     CALL read_param('callrad',.true.,callrad,'appel rayonnemen')
     56    CALL read_param('callrad',.true.,callrad,'appel rayonnement')
    5757    CALL read_param('calldifv',.true.,calldifv,'appel difv')
    5858    CALL read_param('calladj',.true.,calladj,'appel adj')
    59     CALL read_param('callcond',.true.,callcond,'appel cond')
    6059    CALL read_param('callsoil',.true.,callsoil,'appel soil')
    61     CALL read_param('season',.true.,season,'appel soil')
    62     CALL read_param('diurnal',.false.,diurnal,'appel soil')
    63     CALL read_param('lverbose',.true.,lverbose,'appel soil')
     60    CALL read_param('season',.true.,season,'with seasonal cycle')
     61    CALL read_param('diurnal',.false.,diurnal,'with diurnal cycle')
     62    CALL read_param('lverbose',.true.,lverbose,'lverbose')
    6463    CALL read_param('period_sort',1.,period_sort,'period sorties en jour')
    6564
  • dynamico_lmdz/simple_physics/phyparam/physics/logging.F90

    r4233 r4235  
    4242  INTEGER, PARAMETER, PUBLIC :: log_level_fatal=1, log_level_error=2, log_level_warn=3, log_level_info=4, log_level_dbg=5
    4343  INTEGER, PUBLIC :: max_log_level = log_level_info
     44  CHARACTER(3), DIMENSION(log_level_dbg), PUBLIC :: dbtag = (/ 'FAT', 'ERR', 'WRN', 'INF', 'DBG' /)
    4445
    4546  PUBLIC :: logging_buf, logging_bufsize, logging_lineno, flush_log, log_gridpoint, &
     
    7374    INTEGER, INTENT(IN) :: lev
    7475    CHARACTER(*), INTENT(IN) :: tag, buf(:)
    75     CHARACTER(3), DIMENSION(log_level_dbg) :: dbtag = (/ 'FAT', 'ERR', 'WRN', 'INF', 'DBG' /)
    7676    CHARACTER(100) :: prefix
    7777    INTEGER :: i
  • dynamico_lmdz/simple_physics/phyparam/physics/read_param_mod.F90

    r4233 r4235  
    4343  INTERFACE read_param
    4444     PROCEDURE read_paramr, read_parami, read_paramb
    45   END INTERFACE
     45  END INTERFACE read_param
    4646
    4747  PUBLIC :: read_param
     
    8686    LOGICAL, INTENT(OUT)     :: val
    8787#ifndef XCODEML
    88     IF(.NOT.ASSOCIATED(read_paramr_plugin)) THEN
     88    IF(.NOT.ASSOCIATED(read_paramb_plugin)) THEN
    8989       CALL missing_plugin('read_paramb','read_param_mod')
    9090       val = defval
  • dynamico_lmdz/simple_physics/phyparam/physics/writefield_mod.F90

    r4229 r4235  
    2424  INTERFACE writefield
    2525     PROCEDURE writefield1, writefield2
    26   END INTERFACE
     26  END INTERFACE writefield
    2727
    2828  PUBLIC :: writefield
Note: See TracChangeset for help on using the changeset viewer.