From 36937b209e1185173f208f7b5248fc6d4cd80f3f Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Tue, 6 Jun 2017 17:31:08 +0200
Subject: [PATCH] Philippe 06/06/2017: removed dependency of INI_FIELD_LIST and
 FIELDLIST_GOTO_MODEL on LCARTESIAN This was a bug for FIELDLIST_GOTO_MODEL
 (LCARTESIAN not always known when called). This is necessary for
 INI_FIELD_LIST to allow it to be called before reading data files.

---
 src/LIB/SURCOUCHE/src/mode_field.f90 | 31 +++++++---------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/src/LIB/SURCOUCHE/src/mode_field.f90 b/src/LIB/SURCOUCHE/src/mode_field.f90
index 8c33ef365..04374da07 100644
--- a/src/LIB/SURCOUCHE/src/mode_field.f90
+++ b/src/LIB/SURCOUCHE/src/mode_field.f90
@@ -96,7 +96,7 @@ CONTAINS
 !
 SUBROUTINE INI_FIELD_LIST(KMODEL)
 !
-USE MODD_CONF, ONLY: LCARTESIAN,NMODEL
+USE MODD_CONF, ONLY: NMODEL
 !
 INTEGER,INTENT(IN),OPTIONAL :: KMODEL
 !
@@ -343,9 +343,6 @@ TFIELDLIST(IDX)%NTYPE      = TYPEINT
 TFIELDLIST(IDX)%NDIMS      = 0
 IDX = IDX+1
 !
-!
-IF (.NOT.LCARTESIAN .OR. TRIM(CPROGRAM) == 'IDEAL') THEN
-!
 IF(IDX>MAXFIELDS) CALL ERR_INI_FIELD_LIST()
 TFIELDLIST(IDX)%CMNHNAME   = 'RPK'
 TFIELDLIST(IDX)%CSTDNAME   = ''
@@ -382,9 +379,6 @@ TFIELDLIST(IDX)%NTYPE      = TYPEREAL
 TFIELDLIST(IDX)%NDIMS      = 0
 IDX = IDX+1
 !
-END IF !.NOT.LCARTESIAN
-!
-!
 IF(IDX>MAXFIELDS) CALL ERR_INI_FIELD_LIST()
 TFIELDLIST(IDX)%CMNHNAME   = 'THINSHELL'
 TFIELDLIST(IDX)%CSTDNAME   = ''
@@ -581,9 +575,6 @@ TFIELDLIST(IDX)%NDIMS      = 2
 ALLOCATE(TFIELDLIST(IDX)%TFIELD_X2D(IMODEL))
 IDX = IDX+1
 !
-!
-IF (.NOT.LCARTESIAN) THEN
-!
 IF(IDX>MAXFIELDS) CALL ERR_INI_FIELD_LIST()
 TFIELDLIST(IDX)%CMNHNAME   = 'MAP'
 !TODO: check stdname
@@ -624,9 +615,6 @@ TFIELDLIST(IDX)%NDIMS      = 2
 ALLOCATE(TFIELDLIST(IDX)%TFIELD_X2D(IMODEL))
 IDX = IDX+1
 !
-END IF !.NOT.LCARTESIAN
-!
-!
 IF(IDX>MAXFIELDS) CALL ERR_INI_FIELD_LIST()
 TFIELDLIST(IDX)%CMNHNAME   = 'ZS'
 TFIELDLIST(IDX)%CSTDNAME   = 'ground_level_altitude'
@@ -3291,7 +3279,6 @@ END SUBROUTINE INI_FIELD_SCALARS
 !
 SUBROUTINE FIELDLIST_GOTO_MODEL(KFROM, KTO)
 !
-USE MODD_CONF, ONLY: LCARTESIAN
 USE MODD_REF
 !
 USE MODD_ADV_n
@@ -3513,11 +3500,9 @@ CALL FIND_FIELD_ID_FROM_MNHNAME('DIRCOSYW',IID,IRESP); TFIELDLIST(IID)%TFIELD_X2
 CALL FIND_FIELD_ID_FROM_MNHNAME('DIRCOSZW',IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XDIRCOSZW
 CALL FIND_FIELD_ID_FROM_MNHNAME('COSSLOPE',IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XCOSSLOPE
 CALL FIND_FIELD_ID_FROM_MNHNAME('SINSLOPE',IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XSINSLOPE
-IF (.NOT.LCARTESIAN) THEN
-  CALL FIND_FIELD_ID_FROM_MNHNAME('MAP',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XMAP
-  CALL FIND_FIELD_ID_FROM_MNHNAME('LAT',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XLAT
-  CALL FIND_FIELD_ID_FROM_MNHNAME('LON',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XLON
-END IF
+CALL FIND_FIELD_ID_FROM_MNHNAME('MAP',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XMAP
+CALL FIND_FIELD_ID_FROM_MNHNAME('LAT',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XLAT
+CALL FIND_FIELD_ID_FROM_MNHNAME('LON',  IID,IRESP); TFIELDLIST(IID)%TFIELD_X2D(KFROM)%DATA => XLON
 !
 ! MODD_TIME_n variables
 !
@@ -3869,11 +3854,9 @@ CALL FIND_FIELD_ID_FROM_MNHNAME('DIRCOSYW',IID,IRESP); XDIRCOSYW => TFIELDLIST(I
 CALL FIND_FIELD_ID_FROM_MNHNAME('DIRCOSZW',IID,IRESP); XDIRCOSZW => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
 CALL FIND_FIELD_ID_FROM_MNHNAME('COSSLOPE',IID,IRESP); XCOSSLOPE => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
 CALL FIND_FIELD_ID_FROM_MNHNAME('SINSLOPE',IID,IRESP); XSINSLOPE => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
-IF (.NOT.LCARTESIAN) THEN
-  CALL FIND_FIELD_ID_FROM_MNHNAME('MAP',  IID,IRESP); XMAP => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
-  CALL FIND_FIELD_ID_FROM_MNHNAME('LAT',  IID,IRESP); XLAT => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
-  CALL FIND_FIELD_ID_FROM_MNHNAME('LON',  IID,IRESP); XLON => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
-END IF
+CALL FIND_FIELD_ID_FROM_MNHNAME('MAP',  IID,IRESP); XMAP => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
+CALL FIND_FIELD_ID_FROM_MNHNAME('LAT',  IID,IRESP); XLAT => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
+CALL FIND_FIELD_ID_FROM_MNHNAME('LON',  IID,IRESP); XLON => TFIELDLIST(IID)%TFIELD_X2D(KTO)%DATA
 !
 ! MODD_TIME_n variables
 !
-- 
GitLab