Skip to content

Commit 22e3eb0

Browse files
committed
add -rnf option in cdfcofdis
* option -rnf can be used for using a runoff file instead of a mask file * in this case, the distance which is computed is the distance to the runoff points. * With this option, distance are computed in all directions, including landward direction. A post-masking may be of interest (see cdfmltmask)
1 parent 7354596 commit 22e3eb0

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/cdfcofdis.f90

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ PROGRAM cdfcofdis
5959

6060
LOGICAL :: lchk
6161
LOGICAL :: lsurf = .FALSE.
62+
LOGICAL :: lrnf = .FALSE.
6263
LOGICAL :: lnc4 = .FALSE. ! Use nc4 with chunking and deflation
6364
!!----------------------------------------------------------------------
6465
CALL ReadCdfNames()
6566
!
6667
narg=iargc()
6768
IF ( narg == 0 ) THEN
6869
PRINT *,' usage : cdfcofdis -H HGR-file -M MSK-file -T gridT.nc [-jperio jperio ]...'
69-
PRINT *,' ... [-surf] [-o OUT-file[ [-nc4] '
70+
PRINT *,' ... [-rnf] [-surf] [-o OUT-file[ [-nc4] '
7071
PRINT *,' '
7172
PRINT *,' PURPOSE :'
7273
PRINT *,' Compute the distance to the coast and create a file with the ',TRIM(cv_out)
@@ -83,6 +84,9 @@ PROGRAM cdfcofdis
8384
PRINT *,' OPTIONS :'
8485
PRINT *,' [-jperio jperio ] : define the NEMO jperio variable for north fold '
8586
PRINT *,' condition. Default is 4.'
87+
PRINT *,' [-rnf ] : use a runoff file instead of mask file '
88+
PRINT *,' In this case the computed distance is the distance to runoff points'
89+
PRINT *,' defined in the file by the variable socoefr. Force -surf option.'
8690
PRINT *,' [-surf ] : only compute distance at the surface.'
8791
PRINT *,' [-o OUT-file ] : specify name of the output file instead of ', TRIM(cf_out)
8892
PRINT *,' [-nc4 ] : Use netcdf4 output with chunking and deflation level 1.'
@@ -109,12 +113,21 @@ PROGRAM cdfcofdis
109113
! options
110114
CASE ( '-jperio') ; CALL getarg(ijarg, cldum ) ; ijarg=ijarg+1 ; READ(cldum, * ) nperio
111115
CASE ( '-surf' ) ; lsurf = .TRUE.
116+
CASE ( '-rnf' ) ; lrnf = .TRUE. ; lsurf =.TRUE. ; cn_tmask='socoefr'
112117
CASE ( '-o' ) ; CALL getarg(ijarg, cf_out) ; ijarg=ijarg+1
113118
CASE ( '-nc4' ) ; lnc4 = .TRUE.
114119
CASE DEFAULT ; PRINT *,' ERROR : ', TRIM(cldum),' : unknown option.' ; STOP 99
115120
END SELECT
116121
ENDDO
117122

123+
IF ( lrnf ) THEN
124+
PRINT *, ' WORKING WITH RUNOFF FILE :'
125+
PRINT *, ' RUNOFF FILE : ', TRIM(cn_fmsk)
126+
PRINT *, ' VARIABLE : ', TRIM(cn_tmask)
127+
PRINT *, ' '
128+
PRINT *, ' -surf OPTION forced !'
129+
ENDIF
130+
118131
lchk = chkfile ( cn_fhgr )
119132
lchk = lchk .OR. chkfile ( cn_fmsk )
120133
lchk = lchk .OR. chkfile ( cf_tfil )
@@ -218,6 +231,7 @@ SUBROUTINE cofdis(kpk)
218231
PRINT *,'WORKING for level ', jk, nperio
219232
pdct(:,:) = 0.e0
220233
tmask(:,:)=getvar(cn_fmsk,cn_tmask,jk,jpi,jpj)
234+
WHERE (tmask /= 0 ) tmask=1
221235
DO jj = 1, jpjm1
222236
DO ji = 1, jpim1 ! vector loop
223237
umask(ji,jj) = tmask(ji,jj ) * tmask(ji+1,jj )
@@ -341,15 +355,24 @@ SUBROUTINE cofdis(kpk)
341355
DO jj = 1, jpj
342356
PRINT *, jj
343357
DO ji = 1, jpi
344-
IF( tmask(ji,jj) == 0. ) THEN
358+
IF ( lrnf ) THEN ! we compute distance even where socoefr =0
359+
DO jl = 1, icoast
360+
zdis(jl) = ( zxt(ji,jj) - zxc(jl) )**2 &
361+
& + ( zyt(ji,jj) - zyc(jl) )**2 &
362+
& + ( zzt(ji,jj) - zzc(jl) )**2
363+
END DO
364+
pdct(ji,jj) = ra * SQRT( MINVAL( zdis(1:icoast) ) )
365+
ELSE ! Distance is computed only for non masked cells.
366+
IF( tmask(ji,jj) == 0. ) THEN
345367
pdct(ji,jj) = 0.
346-
ELSE
368+
ELSE
347369
DO jl = 1, icoast
348370
zdis(jl) = ( zxt(ji,jj) - zxc(jl) )**2 &
349371
& + ( zyt(ji,jj) - zyc(jl) )**2 &
350372
& + ( zzt(ji,jj) - zzc(jl) )**2
351373
END DO
352374
pdct(ji,jj) = ra * SQRT( MINVAL( zdis(1:icoast) ) )
375+
ENDIF
353376
ENDIF
354377
END DO
355378
END DO

0 commit comments

Comments
 (0)