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 5879 for branches/UKMO/icebergs_restart_single_file/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90 – NEMO

Ignore:
Timestamp:
2015-11-12T15:52:57+01:00 (8 years ago)
Author:
davestorkey
Message:

UKMO icebergs_single_restart_branch: Bug fixes. This version of the code now produces
bit-comparable results with old code if starting from multiple restarts or a single
restart file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/icebergs_restart_single_file/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90

    r5865 r5879  
    7070      TYPE(iceberg)                ::   localberg ! NOT a pointer but an actual local variable 
    7171      TYPE(point)                  ::   localpt   ! NOT a pointer but an actual local variable 
    72       REAL(wp), DIMENSION(1,nkounts) ::   rdata_in  
     72      REAL(wp), DIMENSION(1,nkounts) :: zdata_in 
     73      INTEGER                      ::   ii,ij 
    7374      !!---------------------------------------------------------------------- 
    7475 
     
    8384 
    8485         ibergs_in_file = iom_file(ncid)%lenuld 
    85          IF(lwp) WRITE(numout,*) '>>> Number of bergs in local file : ',ibergs_in_file 
    8686         DO jn = 1,ibergs_in_file 
    8787 
     
    9292            CALL iom_get( ncid, 'yj'     ,localpt%yj  , ktime=jn ) 
    9393 
    94             IF(lwp) WRITE(numout, *) '>>> Found iceberg ',jn,' at (i,j) ',localpt%xi,',',localpt%yj 
    95             IF(lwp) WRITE(numout, *) '>>> nldi, nlei, nldj, nlej, nimpp, njmpp ',nldi, nlei, nldj, nlej, nimpp, njmpp 
    96  
    97             ! Only proceed if this iceberg is on the local processor (including halos). 
    98             IF ( localpt%xi .GE. nimpp .AND. localpt%xi .LE. nimpp+jpi-1 .AND. & 
    99            &     localpt%yj .GE. njmpp .AND. localpt%yj .LE. njmpp+jpj-1 ) THEN            
    100  
    101                CALL iom_get( ncid, jpdom_unknown, 'number'       , (/rdata_in(1,:)/) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) ) 
    102                localberg%number(:) = INT(rdata_in(1,:)) 
     94            ii = INT( localpt%xi + 0.5 ) 
     95            ij = INT( localpt%yj + 0.5 ) 
     96            ! Only proceed if this iceberg is on the local processor (excluding halos). 
     97            IF ( ii .GE. nldi+nimpp-1 .AND. ii .LE. nlei+nimpp-1 .AND. & 
     98           &     ij .GE. nldj+njmpp-1 .AND. ij .LE. nlej+njmpp-1 ) THEN            
     99 
     100               CALL iom_get( ncid, jpdom_unknown, 'number'       , (/zdata_in(1,:)/) , ktime=jn, kstart=(/1/), kcount=(/nkounts/) ) 
     101               localberg%number(:) = INT(zdata_in(1,:)) 
    103102               CALL iom_get( ncid, 'mass_scaling' , localberg%mass_scaling, ktime=jn ) 
    104103               CALL iom_get( ncid, 'lon'          , localpt%lon           , ktime=jn ) 
     
    110109               CALL iom_get( ncid, 'width'        , localpt%width         , ktime=jn ) 
    111110               CALL iom_get( ncid, 'length'       , localpt%length        , ktime=jn ) 
    112                CALL iom_get( ncid, 'year'         , rdata_in(1,1)         , ktime=jn ) 
    113                localpt%year = INT(rdata_in(1,1)) 
     111               CALL iom_get( ncid, 'year'         , zdata_in(1,1)         , ktime=jn ) 
     112               localpt%year = INT(zdata_in(1,1)) 
    114113               CALL iom_get( ncid, 'day'          , localpt%day           , ktime=jn ) 
    115114               CALL iom_get( ncid, 'mass_of_bits' , localpt%mass_of_bits  , ktime=jn ) 
     
    117116 
    118117               ! 
    119                IF(lwp) WRITE(numout, *) '>>> Initialising iceberg ',jn,' at (i,j) ',localpt%xi,',',localpt%yj 
    120118               CALL icb_utl_add( localberg, localpt ) 
    121119 
     
    132130      CALL iom_get( ncid, jpdom_autoglo_xy, 'stored_ice'  , berg_grid%stored_ice, kstart=(/1,1,1/), kcount=(/1,1,nclasses/) ) 
    133131       
    134       CALL iom_get( ncid, jpdom_unknown, 'kount' , (/rdata_in(1,:)/) ) 
    135       num_bergs(:) = INT(rdata_in(1,:)) 
     132      CALL iom_get( ncid, jpdom_unknown, 'kount' , (/zdata_in(1,:)/) ) 
     133      num_bergs(:) = INT(zdata_in(1,:)) 
    136134 
    137135      ! Finish up 
     
    143141         WRITE(numout,'(2(a,i5))') 'icebergs, read_restart_bergs: # bergs =',jn,' on PE',narea-1 
    144142      IF( lk_mpp ) THEN 
    145          CALL mpp_sum(ibergs_in_file) 
     143         ! Only mpp_sum ibergs_in_file if we are reading from multiple restart files.  
     144         WRITE(numout,*) 'iom_file(ncid)%name : ',iom_file(ncid)%name 
     145         WRITE(numout,*) "INDEX(iom_file(ncid)%name,'icebergs.nc' ) : ",INDEX(iom_file(ncid)%name,'icebergs.nc' ) 
     146         IF( INDEX(iom_file(ncid)%name,'icebergs.nc' ) .EQ. 0 ) CALL mpp_sum(ibergs_in_file) 
    146147         CALL mpp_sum(jn) 
    147148      ENDIF 
Note: See TracChangeset for help on using the changeset viewer.