New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 11641 for NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles – NEMO

Ignore:
Timestamp:
2019-10-02T15:12:32+02:00 (5 years ago)
Author:
acc
Message:

Branch 2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles. Further substantive changes to the BDY routines that read multiple copies of some namelists from namelist_cfg. Special treatment is required to replicate the original behaviour with internal files. These changes emulate previous behaviour but removal of the reliance on multiple, same-named namelist blocks would be preferable.

Location:
NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/BDY
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/BDY/bdydta.F90

    r11536 r11641  
    373373      INTEGER ::   ierror, ios     !  
    374374      ! 
     375      INTEGER ::   nbdy_rdstart, nbdy_loc 
     376      CHARACTER(LEN=50)                      ::   cerrmsg       ! error string 
    375377      CHARACTER(len=3)                       ::   cl3           !  
    376378      CHARACTER(len=100)                     ::   cn_dir        ! Root directory for location of data files 
     
    415417      ! Read namelists 
    416418      ! -------------- 
    417       REWIND(numnam_cfg) 
     419      nbdy_rdstart = 1 
    418420      DO jbdy = 1, nb_bdy 
    419421 
     
    421423         WRITE(ctmp2, '(a,i2)') 'block nambdy_dta number ', jbdy 
    422424 
    423          ! There is only one nambdy_dta block in namelist_ref -> use it for each bdy so we do a rewind  
    424          REWIND(numnam_ref) 
     425         ! There is only one nambdy_dta block in namelist_ref -> use it for each bdy so we read from the beginning 
    425426         READ  ( numnam_ref, nambdy_dta, IOSTAT = ios, ERR = 901) 
    426427901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_dta in reference namelist' ) 
     
    431432            & .OR. ( dta_bdy(jbdy)%lneed_tra   .AND.       nn_tra_dta(jbdy)    == 1 )   & 
    432433            & .OR. ( dta_bdy(jbdy)%lneed_ice   .AND.       nn_ice_dta(jbdy)    == 1 )   )   THEN 
    433             ! WARNING: we don't do a rewind here, each bdy reads its own nambdy_dta block one after another 
    434             READ  ( numnam_cfg, nambdy_dta, IOSTAT = ios, ERR = 902 ) 
     434            ! 
     435            ! Need to support possibility of reading more than one 
     436            ! nambdy_dta from the namelist_cfg internal file. 
     437            ! Do this by finding the jbdy'th occurence of nambdy_dta in the 
     438            ! character buffer as the starting point. 
     439            ! 
     440            nbdy_loc = INDEX( numnam_cfg( nbdy_rdstart: ), 'nambdy_dta' ) 
     441            IF( nbdy_loc .GT. 0 ) THEN 
     442               nbdy_rdstart = nbdy_rdstart + nbdy_loc 
     443            ELSE 
     444               WRITE(cerrmsg,'(A,I4,A)') 'Error: entry number ',jbdy,' of nambdy_dta not found' 
     445               ios = -1 
     446               CALL ctl_nam ( ios , cerrmsg ) 
     447            ENDIF 
     448            nbdy_rdstart = MAX( 1, nbdy_rdstart - 2 ) 
     449            READ  ( numnam_cfg( nbdy_rdstart: ), nambdy_dta, IOSTAT = ios, ERR = 902) 
    435450902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_dta in configuration namelist' ) 
    436451            IF(lwm) WRITE( numond, nambdy_dta )            
  • NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/BDY/bdyini.F90

    r11536 r11641  
    7575      ! Read namelist parameters 
    7676      ! ------------------------ 
    77       REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries 
    7877      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 901) 
    7978901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist' ) 
     
    9392      cn_ice         (2:jp_bdy) = cn_ice         (1) 
    9493      nn_ice_dta     (2:jp_bdy) = nn_ice_dta     (1) 
    95       REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries 
    9694      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 902 ) 
    9795902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist' ) 
     
    364362      ! ------------------------------------------------- 
    365363 
    366       REWIND( numnam_cfg )      
    367364      nblendta(:,:) = 0 
    368365      nbdysege = 0 
     
    10791076      INTEGER          ::   ios                 ! Local integer output status for namelist read 
    10801077      INTEGER          ::   nbdyind, nbdybeg, nbdyend 
     1078      INTEGER          ::   nbdy_count, nbdy_rdstart, nbdy_loc 
    10811079      CHARACTER(LEN=1) ::   ctypebdy   !     -        -  
     1080      CHARACTER(LEN=50)::   cerrmsg    !     -        -  
    10821081      NAMELIST/nambdy_index/ ctypebdy, nbdyind, nbdybeg, nbdyend 
    10831082      !!---------------------------------------------------------------------- 
    1084  
    1085       ! No REWIND here because may need to read more than one nambdy_index namelist. 
    1086       ! Read only namelist_cfg to avoid unseccessfull overwrite  
    1087       ! keep full control of the configuration namelist 
    1088       READ  ( numnam_cfg, nambdy_index, IOSTAT = ios, ERR = 904 ) 
     1083      ! Need to support possibility of reading more than one nambdy_index from 
     1084      ! the namelist_cfg internal file. 
     1085      ! Do this by finding the kb_bdy'th occurence of nambdy_index in the 
     1086      ! character buffer as the starting point. 
     1087      nbdy_rdstart = 1 
     1088      DO nbdy_count = 1, kb_bdy 
     1089       nbdy_loc = INDEX( numnam_cfg( nbdy_rdstart: ), 'nambdy_index' ) 
     1090       IF( nbdy_loc .GT. 0 ) THEN 
     1091          nbdy_rdstart = nbdy_rdstart + nbdy_loc 
     1092       ELSE 
     1093          WRITE(cerrmsg,'(A,I4,A)') 'Error: entry number ',kb_bdy,' of nambdy_index not found' 
     1094          ios = -1 
     1095          CALL ctl_nam ( ios , cerrmsg ) 
     1096       ENDIF 
     1097      END DO 
     1098      nbdy_rdstart = MAX( 1, nbdy_rdstart - 2 ) 
     1099      READ  ( numnam_cfg( nbdy_rdstart: ), nambdy_index, IOSTAT = ios, ERR = 904) 
    10891100904   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_index in configuration namelist' ) 
    10901101      IF(lwm) WRITE ( numond, nambdy_index ) 
  • NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles/src/OCE/BDY/bdytides.F90

    r11536 r11641  
    7171      INTEGER, DIMENSION(3)                     ::   ilen0       !: length of boundary data (from OBC arrays) 
    7272      INTEGER                                   ::   ios                 ! Local integer output status for namelist read 
     73      INTEGER                                   ::   nbdy_rdstart, nbdy_loc 
     74      CHARACTER(LEN=50)                         ::   cerrmsg             !: error string 
    7375      CHARACTER(len=80)                         ::   clfile              !: full file name for tidal input file  
    7476      REAL(wp),ALLOCATABLE, DIMENSION(:,:,:)    ::   dta_read            !: work space to read in tidal harmonics data 
     
    8486      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' 
    8587 
    86       REWIND(numnam_cfg) 
    87  
     88 
     89      nbdy_rdstart = 1 
    8890      DO ib_bdy = 1, nb_bdy 
    8991         IF( nn_dyn2d_dta(ib_bdy) >= 2 ) THEN 
     
    9496            filtide(:) = '' 
    9597 
    96             REWIND( numnam_ref ) 
    9798            READ  ( numnam_ref, nambdy_tide, IOSTAT = ios, ERR = 901) 
    9899901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_tide in reference namelist' ) 
    99             ! Don't REWIND here - may need to read more than one of these namelists.  
    100             READ  ( numnam_cfg, nambdy_tide, IOSTAT = ios, ERR = 902 ) 
     100            ! 
     101            ! Need to support possibility of reading more than one 
     102            ! nambdy_tide from the namelist_cfg internal file. 
     103            ! Do this by finding the ib_bdy'th occurence of nambdy_tide in the 
     104            ! character buffer as the starting point. 
     105            ! 
     106            nbdy_loc = INDEX( numnam_cfg( nbdy_rdstart: ), 'nambdy_tide' ) 
     107            IF( nbdy_loc .GT. 0 ) THEN 
     108               nbdy_rdstart = nbdy_rdstart + nbdy_loc 
     109            ELSE 
     110               WRITE(cerrmsg,'(A,I4,A)') 'Error: entry number ',ib_bdy,' of nambdy_tide not found' 
     111               ios = -1 
     112               CALL ctl_nam ( ios , cerrmsg ) 
     113            ENDIF 
     114            nbdy_rdstart = MAX( 1, nbdy_rdstart - 2 ) 
     115            READ  ( numnam_cfg( nbdy_rdstart: ), nambdy_tide, IOSTAT = ios, ERR = 902) 
    101116902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_tide in configuration namelist' ) 
    102117            IF(lwm) WRITE ( numond, nambdy_tide ) 
Note: See TracChangeset for help on using the changeset viewer.