[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------- |
---|
| 3 | CPL_Initialize () |
---|
| 4 | { |
---|
| 5 | IGCM_debug_PushStack "CPL_Initialize" |
---|
| 6 | |
---|
| 7 | echo INITIALIZE CPL !!! |
---|
| 8 | |
---|
[1785] | 9 | # Local function to find parameters in LMDZ .def files |
---|
| 10 | lmdzgrep () { |
---|
| 11 | grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}' |
---|
| 12 | } |
---|
| 13 | |
---|
[677] | 14 | RESOL_CPL=$( echo $RESOL | awk "-F-" '{print $1}' ) |
---|
[673] | 15 | |
---|
[653] | 16 | #D- MPI context used to launch the coupled model |
---|
| 17 | LIBMPI=$(cat ${SUBMIT_DIR}/../.libmpi) |
---|
| 18 | echo LIBMPI=${LIBMPI} |
---|
[396] | 19 | |
---|
[653] | 20 | #D- MPISUSPEND=ON required for MPMD mode used by oasis |
---|
[648] | 21 | export MPISUSPEND=ON |
---|
| 22 | |
---|
[396] | 23 | IGCM_sys_build_run_file ${LIBMPI} |
---|
| 24 | |
---|
[814] | 25 | CPL_OkDay="n" |
---|
| 26 | CPL_OkMonth="n" |
---|
[808] | 27 | |
---|
| 28 | for CPL_Frequency in ${config_CPL_WriteFrequency} ; do |
---|
| 29 | case ${CPL_Frequency} in |
---|
| 30 | *D|*d) CPL_OkDay="y" ;; |
---|
| 31 | *M) CPL_OkMonth="y" ;; |
---|
| 32 | esac |
---|
| 33 | done |
---|
| 34 | |
---|
[396] | 35 | IGCM_debug_PopStack "CPL_Initialize" |
---|
[808] | 36 | |
---|
[396] | 37 | } |
---|
| 38 | |
---|
| 39 | #----------------------------------- |
---|
| 40 | CPL_Update () |
---|
| 41 | { |
---|
| 42 | IGCM_debug_PushStack "CPL_Update" |
---|
| 43 | |
---|
[653] | 44 | ############ Update Time and Counters ############## |
---|
| 45 | ##-- Calcul de la duree du job (en secondes) |
---|
| 46 | (( D_JOB_SEC = 3600 * 24 * PeriodLengthInDays )) |
---|
[396] | 47 | |
---|
[811] | 48 | # nleapy configuration |
---|
| 49 | case ${config_UserChoices_CalendarType} in |
---|
| 50 | leap|gregorian) |
---|
| 51 | CPL_calendar=1;; |
---|
| 52 | noleap) |
---|
| 53 | CPL_calendar=0;; |
---|
| 54 | 360d) |
---|
| 55 | CPL_calendar=30;; |
---|
| 56 | *) |
---|
| 57 | CPL_calendar=30 |
---|
| 58 | esac |
---|
| 59 | |
---|
[653] | 60 | ############ Update Other Parameters ############## |
---|
[902] | 61 | ## Read Output_mode option in oasis.card --> Put "y" to have coupling variables in ouptut files |
---|
[814] | 62 | CPL_OutputMode="n" |
---|
[902] | 63 | IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices OutputMode |
---|
| 64 | eval CPL_OutputMode=\${oasis_UserChoices_OutputMode} > /dev/null 2>&1 |
---|
[808] | 65 | echo CPL_OutputMode = ${CPL_OutputMode} |
---|
| 66 | CPL_OutputVar='EXPORTED' |
---|
| 67 | if [ ${CPL_OutputMode} = y ] ; then |
---|
| 68 | CPL_OutputVar='EXPOUT' |
---|
[653] | 69 | fi |
---|
[396] | 70 | |
---|
[1548] | 71 | ## Calculate lag for transfer of fields from atmosphere -> ocean. |
---|
| 72 | ## LAG_ATM="1day in sec"/day_step * iphysiq/nsplit_phys |
---|
| 73 | ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files |
---|
| 74 | day_step=$( lmdzgrep day_step gcm.def ) |
---|
| 75 | iphysiq=$( lmdzgrep iphysiq gcm.def ) |
---|
| 76 | nsplit_phys=$( lmdzgrep nsplit_phys physiq.def ) |
---|
| 77 | |
---|
| 78 | (( LAG_ATM = 86400 / day_step * iphysiq / nsplit_phys )) |
---|
| 79 | |
---|
[653] | 80 | ############ Update Parameter Files ############## |
---|
| 81 | sed -e "s/<initial_date>/${PeriodDateBegin}/" \ |
---|
[811] | 82 | -e "s/<calendar_type>/${CPL_calendar}/" \ |
---|
[653] | 83 | -e "s/<total_time>/${D_JOB_SEC}/" \ |
---|
| 84 | -e "s/<lib_mpi>/${LIBMPI}/" \ |
---|
| 85 | -e "s/<nproc_atm>/${NUM_PROC_ATM}/g" \ |
---|
| 86 | -e "s/<nproc_oce>/${NUM_PROC_OCE}/g" \ |
---|
[808] | 87 | -e "s/<output_mode>/${CPL_OutputVar}/g" \ |
---|
[1548] | 88 | -e "s/<lag_atm>/${LAG_ATM}/g" \ |
---|
[396] | 89 | namcouple > namcouple.tmp |
---|
[808] | 90 | IGCM_sys_Mv namcouple.tmp namcouple |
---|
[396] | 91 | |
---|
| 92 | # Unused files we want to remove |
---|
| 93 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=trace |
---|
| 94 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=gweights |
---|
| 95 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=mweights |
---|
| 96 | eval FileToBeDeleted[${#FileToBeDeleted[@]}]=anaisout |
---|
| 97 | |
---|
| 98 | IGCM_debug_PopStack "CPL_Update" |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | #----------------------------------- |
---|
| 102 | CPL_Finalize () |
---|
| 103 | { |
---|
| 104 | IGCM_debug_PushStack "CPL_Finalize" |
---|
| 105 | |
---|
[808] | 106 | DATE_CPL=$(echo ${PeriodDateBegin} | sed -e "{ s/^\(.\{4\}\)/\1-/;s/\(-.\{2\}\)/\1-/; }"); |
---|
| 107 | DATE_CPL=${DATE_CPL}"T00:00:00" |
---|
| 108 | |
---|
| 109 | echo ${DATE_CPL} ${CPL_OutputMode} ${CPL_OkDay} ${CPL_OkMonth} |
---|
[561] | 110 | |
---|
[808] | 111 | if [ "${CPL_OutputMode}" = "y" ] ; then |
---|
| 112 | |
---|
| 113 | [[ ${CPL_OkDay} = "y" ]] && date >TEMPO_1D_cpl_atm.nc |
---|
| 114 | [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc |
---|
| 115 | [[ ${CPL_OkDay} = "y" ]] && date >TEMPO_1D_cpl_oce.nc |
---|
| 116 | [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc |
---|
| 117 | |
---|
| 118 | fi |
---|
| 119 | |
---|
[396] | 120 | echo FINALIZE CPL !!! |
---|
| 121 | |
---|
| 122 | IGCM_debug_PopStack "CPL_Finalize" |
---|
| 123 | } |
---|