2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755 integer, intent(in) :: ng
2756 integer, intent(out) :: rc
2757
2758 TYPE (ESMF_GridComp) :: model
2759
2760
2761
2762 logical :: LoadIt, isPresent
2763 logical :: got_stress(2), got_wind(2)
2764# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2765 logical :: got_RhoAir, got_Wstar, got_wind_sbl(2)
2766# endif
2767
2768 integer :: Istr, Iend, Jstr, Jend
2769 integer :: IstrR, IendR, JstrR, JendR
2770 integer :: LBi, UBi, LBj, UBj
2771 integer :: ImportCount, Tindex
2772 integer :: localDE, localDEcount, localPET, tile
2773 integer :: year, month, day, hour, minutes, seconds, sN, SD
2774 integer :: gtype, id, ifield, ifld, i, is, j
2775
2776# ifdef TIME_INTERP
2777 integer, save :: record = 0
2778
2779# endif
2780 real (dp), parameter :: eps = 1.0e-10_dp
2781
2782 real (dp) :: TimeInDays, Time_Current, Tmin, Tmax, Tstr, Tend
2783# ifdef TIME_INTERP
2784 real (dp) :: MyTimeInDays
2785# endif
2786 real (dp) :: Fseconds, ROMSclockTime
2787 real (dp) :: MyTintrp(2), MyVtime(2)
2788
2789 real (dp) :: MyFmax(2), MyFmin(2), Fmin(2), Fmax(2), Fval
2790 real (dp) :: add_offset, romsScale, scale, cff1, cff2, cff3
2791 real (dp) :: FreshWaterScale, StressScale, TracerFluxScale
2792# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2793 real (dp) :: Urel, Vrel, Wmag, Wrel
2794# endif
2795 real (dp) :: AttValues(14)
2796
2797 real (dp), pointer :: ptr2d(:,:) => null()
2798
2799# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2800 real (dp), allocatable :: RhoAir(:,:), Wstar(:,:)
2801 real (dp), allocatable :: Uwrk(:,:), Vwrk(:,:)
2802 real (dp), allocatable :: Xwind(:,:), Ywind(:,:)
2803# endif
2804 real (dp), allocatable :: Ustress(:,:), Vstress(:,:)
2805 real (dp), allocatable :: Uwind(:,:), Vwind(:,:)
2806
2807 character (len=22) :: MyDate(2)
2808# ifdef TIME_INTERP
2809 character (len=22) :: MyDateString(1,1,1)
2810# endif
2811 character (len=22) :: Time_CurrentString
2812 character (len=40) :: AttName
2813
2814 character (len=*), parameter :: MyFile = &
2815 & __FILE__//", ROMS_Import"
2816
2817 character (ESMF_MAXSTR) :: cname, ofile
2818 character (ESMF_MAXSTR), allocatable :: ImportNameList(:)
2819
2820 TYPE (ESMF_AttPack) :: AttPack
2821 TYPE (ESMF_Clock) :: clock
2822 TYPE (ESMF_Field) :: field
2823 TYPE (ESMF_Time) :: CurrentTime
2824 TYPE (ESMF_VM) :: vm
2825
2826# ifdef TIME_INTERP
2827
2828 sourcefile=myfile
2829# endif
2830
2831
2832
2833
2834
2835 IF (esm_track) THEN
2836 WRITE (trac,'(a,a,i0)') '==> Entering ROMS_Import', &
2837 & ', PET', petrank
2838 FLUSH (trac)
2839 END IF
2840 rc=esmf_success
2841
2842
2843
2844
2845
2846 CALL esmf_gridcompget (model, &
2847 & clock=clock, &
2848 & localpet=localpet, &
2849 & vm=vm, &
2850 & name=cname, &
2851 & rc=rc)
2852 IF (esmf_logfounderror(rctocheck=rc, &
2853 & msg=esmf_logerr_passthru, &
2854 & line=__line__, &
2855 & file=myfile)) THEN
2856 RETURN
2857 END IF
2858
2859
2860
2861
2862
2863 CALL esmf_gridget (models(iroms)%grid(ng), &
2864 & localdecount=localdecount, &
2865 & rc=rc)
2866 IF (esmf_logfounderror(rctocheck=rc, &
2867 & msg=esmf_logerr_passthru, &
2868 & line=__line__, &
2869 & file=myfile)) THEN
2870 RETURN
2871 END IF
2872
2873
2874
2875 tile=localpet
2876
2877 lbi=bounds(ng)%LBi(tile)
2878 ubi=bounds(ng)%UBi(tile)
2879 lbj=bounds(ng)%LBj(tile)
2880 ubj=bounds(ng)%UBj(tile)
2881
2882 istrr=bounds(ng)%IstrR(tile)
2883 iendr=bounds(ng)%IendR(tile)
2884 jstrr=bounds(ng)%JstrR(tile)
2885 jendr=bounds(ng)%JendR(tile)
2886
2887 istr=bounds(ng)%Istr(tile)
2888 iend=bounds(ng)%Iend(tile)
2889 jstr=bounds(ng)%Jstr(tile)
2890 jend=bounds(ng)%Jend(tile)
2891
2892
2893
2894
2895
2896 CALL esmf_clockget (clock, &
2897 & currtime=currenttime, &
2898 & rc=rc)
2899 IF (esmf_logfounderror(rctocheck=rc, &
2900 & msg=esmf_logerr_passthru, &
2901 & line=__line__, &
2902 & file=myfile)) THEN
2903 RETURN
2904 END IF
2905
2906 CALL esmf_timeget (currenttime, &
2907 & yy=year, &
2908 & mm=month, &
2909 & dd=day, &
2910 & h =hour, &
2911 & m =minutes, &
2912 & s =seconds, &
2913 & sn=sn, &
2914 & sd=sd, &
2915 & rc=rc)
2916 IF (esmf_logfounderror(rctocheck=rc, &
2917 & msg=esmf_logerr_passthru, &
2918 & line=__line__, &
2919 & file=myfile)) THEN
2920 RETURN
2921 END IF
2922
2923 CALL esmf_timeget (currenttime, &
2924 & s_r8=time_current, &
2925 & timestring=time_currentstring, &
2926 & rc=rc)
2927 IF (esmf_logfounderror(rctocheck=rc, &
2928 & msg=esmf_logerr_passthru, &
2929 & line=__line__, &
2930 & file=myfile)) THEN
2931 RETURN
2932 END IF
2933 timeindays=time_current/86400.0_dp
2934 is=index(time_currentstring, 'T')
2935 IF (is.gt.0) time_currentstring(is:is)=' '
2936
2937
2938
2939
2940
2941
2942
2943 fseconds=real(seconds,dp)+real(sn,dp)/real(sd,dp)
2944 CALL roms_clock (year, month, day, hour, minutes, fseconds, &
2945 & romsclocktime)
2946
2947
2948
2949
2950
2951 CALL esmf_stateget (models(iroms)%ImportState(ng), &
2952 & itemcount=importcount, &
2953 & rc=rc)
2954 IF (esmf_logfounderror(rctocheck=rc, &
2955 & msg=esmf_logerr_passthru, &
2956 & line=__line__, &
2957 & file=myfile)) THEN
2958 RETURN
2959 END IF
2960
2961 IF (.not.allocated(importnamelist)) THEN
2962 allocate ( importnamelist(importcount) )
2963 END IF
2964 CALL esmf_stateget (models(iroms)%ImportState(ng), &
2965 & itemnamelist=importnamelist, &
2966 & rc=rc)
2967 IF (esmf_logfounderror(rctocheck=rc, &
2968 & msg=esmf_logerr_passthru, &
2969 & line=__line__, &
2970 & file=myfile)) THEN
2971 RETURN
2972 END IF
2973
2974# ifdef TIME_INTERP
2975
2976
2977
2978
2979
2980 IF (petlayoutoption.eq.'CONCURRENT') THEN
2981 record=record+1
2982 END IF
2983# endif
2984
2985
2986
2987
2988
2989
2990
2991
2992 got_stress(1:2)=.false.
2993 got_wind(1:2)=.false.
2994# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
2995 got_rhoair=.false.
2996 got_wstar=.false.
2997 got_wind_sbl(1:2)=.false.
2998# endif
2999
3000
3001
3002 fld_loop : DO ifld=1,importcount
3003 id=field_index(models(iroms)%ImportField, importnamelist(ifld))
3004
3005
3006
3007 CALL esmf_stateget (models(iroms)%ImportState(ng), &
3008 & trim(importnamelist(ifld)), &
3009 & field, &
3010 & rc=rc)
3011 IF (esmf_logfounderror(rctocheck=rc, &
3012 & msg=esmf_logerr_passthru, &
3013 & line=__line__, &
3014 & file=myfile)) THEN
3015 RETURN
3016 END IF
3017
3018# ifdef TIME_INTERP
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028 IF (petlayoutoption.eq.'CONCURRENT') THEN
3029 CALL netcdf_get_ivar (ng, inlm, attfilename, 'Tindex', &
3030 & models(iroms)%ImportField(id)%Tindex, &
3031 & start=(/iroms,id,record/), &
3032 & total=(/1,1,1/))
3033 IF (founderror(exit_flag, noerror, __line__, &
3034 & myfile)) THEN
3035 rc=esmf_rc_file_read
3036 RETURN
3037 END IF
3038
3039 is=models(iroms)%ImportField(id)%Tindex
3040 CALL netcdf_get_svar (ng, inlm, attfilename, 'Date', &
3041 & mydatestring, &
3042 & start=(/1,iroms,id,record/), &
3043 & total=(/22,1,1,1/))
3044 IF (founderror(exit_flag, noerror, __line__, &
3045 & myfile)) THEN
3046 rc=esmf_rc_file_read
3047 RETURN
3048 END IF
3049 models(iroms)%ImportField(id)%DateString(is)= &
3050 & mydatestring(1,1,1)
3051
3052 CALL netcdf_get_time (ng, inlm, attfilename, 'Tcurrent', &
3053 & rclock%DateNumber, mytimeindays, &
3054 & start=(/iroms,id,record/), &
3055 & total=(/1,1,1/))
3056 IF (founderror(exit_flag, noerror, __line__, &
3057 & myfile)) THEN
3058 rc=esmf_rc_file_read
3059 RETURN
3060 END IF
3061
3062 CALL netcdf_get_time (ng, inlm, attfilename, 'Tstr', &
3063 & rclock%DateNumber, &
3064 & models(iroms)%ImportField(id)%Tstr, &
3065 & start=(/iroms,id,record/), &
3066 & total=(/1,1,1/))
3067 IF (founderror(exit_flag, noerror, __line__, &
3068 & myfile)) THEN
3069 rc=esmf_rc_file_read
3070 RETURN
3071 END IF
3072
3073 CALL netcdf_get_time (ng, inlm, attfilename, 'Tend', &
3074 & rclock%DateNumber, &
3075 & models(iroms)%ImportField(id)%Tend, &
3076 & start=(/iroms,id,record/), &
3077 & total=(/1,1,1/))
3078 IF (founderror(exit_flag, noerror, __line__, &
3079 & myfile)) THEN
3080 rc=esmf_rc_file_read
3081 RETURN
3082 END IF
3083
3084 CALL netcdf_get_time (ng, inlm, attfilename, 'Tintrp', &
3085 & rclock%DateNumber, &
3086 & models(iroms)%ImportField(id)%Tintrp(is), &
3087 & start=(/iroms,id,record/), &
3088 & total=(/1,1,1/))
3089 IF (founderror(exit_flag, noerror, __line__, &
3090 & myfile)) THEN
3091 rc=esmf_rc_file_read
3092 RETURN
3093 END IF
3094
3095 CALL netcdf_get_time (ng, inlm, attfilename, 'Vtime', &
3096 & rclock%DateNumber, &
3097 & models(iroms)%ImportField(id)%Vtime(is), &
3098 & start=(/iroms,id,record/), &
3099 & total=(/1,1,1/))
3100 IF (founderror(exit_flag, noerror, __line__, &
3101 & myfile)) THEN
3102 rc=esmf_rc_file_read
3103 RETURN
3104 END IF
3105 CALL netcdf_get_time (ng, inlm, attfilename, 'Tmin', &
3106 & rclock%DateNumber, &
3107 & models(iroms)%ImportField(id)%Tmin, &
3108 & start=(/iroms,id,record/), &
3109 & total=(/1,1,1/))
3110 IF (founderror(exit_flag, noerror, __line__, &
3111 & myfile)) THEN
3112 rc=esmf_rc_file_read
3113 RETURN
3114 END IF
3115
3116 CALL netcdf_get_time (ng, inlm, attfilename, 'Tmax', &
3117 & rclock%DateNumber, &
3118 & models(iroms)%ImportField(id)%Tmax, &
3119 & start=(/iroms,id,record/), &
3120 & total=(/1,1,1/))
3121 IF (founderror(exit_flag, noerror, __line__, &
3122 & myfile)) THEN
3123 rc=esmf_rc_file_read
3124 RETURN
3125 END IF
3126 END IF
3127# endif
3128
3129
3130
3131
3132 de_loop : DO localde=0,localdecount-1
3133 CALL esmf_fieldget (field, &
3134 & localde=localde, &
3135 & farrayptr=ptr2d, &
3136 & rc=rc)
3137 IF (esmf_logfounderror(rctocheck=rc, &
3138 & msg=esmf_logerr_passthru, &
3139 & line=__line__, &
3140 & file=myfile)) THEN
3141 RETURN
3142 END IF
3143
3144# ifdef TIME_INTERP_NOT_WORKING
3145
3146
3147
3148 CALL esmf_attributegetattpack (field, &
3149 & 'CustomConvention', &
3150 & 'General', &
3151
3152 & attpack=attpack, &
3153 & ispresent=ispresent, &
3154 & rc=rc)
3155 IF (esmf_logfounderror(rctocheck=rc, &
3156 & msg=esmf_logerr_passthru, &
3157 & line=__line__, &
3158 & file=myfile)) THEN
3159 RETURN
3160 END IF
3161
3162
3163
3164 CALL esmf_attributeget (field, &
3165 & name='TimeInterp', &
3166 & valuelist=attvalues, &
3167 & attpack=attpack, &
3168 & ispresent=ispresent, &
3169 & rc=rc)
3170 IF (esmf_logfounderror(rctocheck=rc, &
3171 & msg=esmf_logerr_passthru, &
3172 & line=__line__, &
3173 & file=myfile)) THEN
3174 RETURN
3175 END IF
3176# endif
3177
3178
3179# ifdef TIME_INTERP
3180
3181
3182
3183
3184
3185
3186
3187
3188# endif
3189
3190 loadit=.true.
3191 scale =models(iroms)%ImportField(id)%scale_factor
3192 add_offset =models(iroms)%ImportField(id)%add_offset
3193 tindex =models(iroms)%ImportField(id)%Tindex
3194# ifdef TIME_INTERP
3195 tmin =models(iroms)%ImportField(id)%Tmin
3196 tmax =models(iroms)%ImportField(id)%Tmax
3197 tstr =models(iroms)%ImportField(id)%Tstr
3198 tend =models(iroms)%ImportField(id)%Tend
3199 mytintrp(1)=models(iroms)%ImportField(id)%Tintrp(1)
3200 mytintrp(2)=models(iroms)%ImportField(id)%Tintrp(2)
3201 myvtime(1) =models(iroms)%ImportField(id)%Vtime(1)
3202 myvtime(2) =models(iroms)%ImportField(id)%Vtime(2)
3203 mydate(1) =models(iroms)%ImportField(id)%DateString(1)
3204 mydate(2) =models(iroms)%ImportField(id)%DateString(2)
3205# endif
3206
3207
3208
3209
3210 freshwaterscale=1.0_dp/rho0
3211 stressscale=1.0_dp/rho0
3212 tracerfluxscale=1.0_dp/(rho0*cp)
3213
3214 fval=ptr2d(istrr,jstrr)
3215 myfmin(1)= missing_dp
3216 myfmax(1)=-missing_dp
3217 myfmin(2)= missing_dp
3218 myfmax(2)=-missing_dp
3219
3220 SELECT CASE (trim(adjustl(importnamelist(ifld))))
3221
3222# if defined BULK_FLUXES || defined ECOSIM || defined ATM_PRESS
3223
3224
3225
3226 CASE ('psfc', 'Pair', 'Pmsl')
3227 romsscale=scale
3228 ifield=idpair
3229 gtype=r2dvar
3230 tindex=3-iinfo(8,ifield,ng)
3231 DO j=jstrr,jendr
3232 DO i=istrr,iendr
3233 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3234 fval=scale*ptr2d(i,j)+add_offset
3235 ELSE
3236 fval=0.0_dp
3237 END IF
3238 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3239 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3240 myfmin(2)=min(myfmin(2),fval)
3241 myfmax(2)=max(myfmax(2),fval)
3242# ifdef TIME_INTERP
3243 forces(ng)%PairG(i,j,tindex)=fval
3244# else
3245 forces(ng)%Pair(i,j)=fval
3246# endif
3247 END DO
3248 END DO
3249# ifndef TIME_INTERP
3250 IF (localde.eq.localdecount-1) THEN
3251 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3252 CALL exchange_r2d_tile (ng, tile, &
3253 & lbi, ubi, lbj, ubj, &
3254 & forces(ng)%Pair)
3255 END IF
3256 CALL mp_exchange2d (ng, tile, inlm, 1, &
3257 & lbi, ubi, lbj, ubj, &
3258 & nghostpoints, &
3259 & ewperiodic(ng), nsperiodic(ng), &
3260 & forces(ng)%Pair)
3261 END IF
3262# endif
3263# endif
3264# if defined BULK_FLUXES || defined ECOSIM || \
3265 (defined shortwave && defined ana_srflux && defined albedo)
3266
3267
3268
3269 CASE ('tsfc', 'Tair')
3270 romsscale=scale
3271 ifield=idtair
3272 gtype=r2dvar
3273 tindex=3-iinfo(8,ifield,ng)
3274 DO j=jstrr,jendr
3275 DO i=istrr,iendr
3276 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3277 fval=scale*ptr2d(i,j)+add_offset
3278 ELSE
3279 fval=0.0_dp
3280 END IF
3281 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3282 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3283 myfmin(2)=min(myfmin(2),fval)
3284 myfmax(2)=max(myfmax(2),fval)
3285# ifdef TIME_INTERP
3286 forces(ng)%TairG(i,j,tindex)=fval
3287# else
3288 forces(ng)%Tair(i,j)=fval
3289# endif
3290 END DO
3291 END DO
3292# ifndef TIME_INTERP
3293 IF (localde.eq.localdecount-1) THEN
3294 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3295 CALL exchange_r2d_tile (ng, tile, &
3296 & lbi, ubi, lbj, ubj, &
3297 & forces(ng)%Tair)
3298 END IF
3299 CALL mp_exchange2d (ng, tile, inlm, 1, &
3300 & lbi, ubi, lbj, ubj, &
3301 & nghostpoints, &
3302 & ewperiodic(ng), nsperiodic(ng), &
3303 & forces(ng)%Tair)
3304 END IF
3305# endif
3306# endif
3307# if defined BULK_FLUXES || defined ECOSIM
3308
3309
3310
3311
3312
3313 CASE ('Qair')
3314 romsscale=scale
3315 ifield=idqair
3316 gtype=r2dvar
3317 tindex=3-iinfo(8,ifield,ng)
3318 DO j=jstrr,jendr
3319 DO i=istrr,iendr
3320 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3321 fval=scale*ptr2d(i,j)+add_offset
3322 ELSE
3323 fval=0.0_dp
3324 END IF
3325 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3326 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3327 myfmin(2)=min(myfmin(2),fval)
3328 myfmax(2)=max(myfmax(2),fval)
3329# ifdef TIME_INTERP
3330 forces(ng)%HairG(i,j,tindex)=fval
3331# else
3332 forces(ng)%Hair(i,j)=fval
3333# endif
3334 END DO
3335 END DO
3336# ifndef TIME_INTERP
3337 IF (localde.eq.localdecount-1) THEN
3338 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3339 CALL exchange_r2d_tile (ng, tile, &
3340 & lbi, ubi, lbj, ubj, &
3341 & forces(ng)%Hair)
3342 END IF
3343 CALL mp_exchange2d (ng, tile, inlm, 1, &
3344 & lbi, ubi, lbj, ubj, &
3345 & nghostpoints, &
3346 & ewperiodic(ng), nsperiodic(ng), &
3347 & forces(ng)%Hair)
3348 END IF
3349# endif
3350# endif
3351# if defined BULK_FLUXES
3352
3353
3354
3355 CASE ('Hair', 'qsfc')
3356 romsscale=scale
3357 ifield=idqair
3358 gtype=r2dvar
3359 tindex=3-iinfo(8,ifield,ng)
3360 DO j=jstrr,jendr
3361 DO i=istrr,iendr
3362 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3363 fval=scale*ptr2d(i,j)+add_offset
3364 ELSE
3365 fval=0.0_dp
3366 END IF
3367 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3368 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3369 myfmin(2)=min(myfmin(2),fval)
3370 myfmax(2)=max(myfmax(2),fval)
3371# ifdef TIME_INTERP
3372 forces(ng)%HairG(i,j,tindex)=fval
3373# else
3374 forces(ng)%Hair(i,j)=fval
3375# endif
3376 END DO
3377 END DO
3378# ifndef TIME_INTERP
3379 IF (localde.eq.localdecount-1) THEN
3380 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3381 CALL exchange_r2d_tile (ng, tile, &
3382 & lbi, ubi, lbj, ubj, &
3383 & forces(ng)%Hair)
3384 END IF
3385 CALL mp_exchange2d (ng, tile, inlm, 1, &
3386 & lbi, ubi, lbj, ubj, &
3387 & nghostpoints, &
3388 & ewperiodic(ng), nsperiodic(ng), &
3389 & forces(ng)%Hair)
3390 END IF
3391# endif
3392# endif
3393# if defined BULK_FLUXES
3394
3395
3396
3397 CASE ('lwrd', 'LWrad')
3398 romsscale=tracerfluxscale
3399 ifield=idlrad
3400 gtype=r2dvar
3401 tindex=3-iinfo(8,ifield,ng)
3402 DO j=jstrr,jendr
3403 DO i=istrr,iendr
3404 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3405 fval=scale*ptr2d(i,j)+add_offset
3406 ELSE
3407 fval=0.0_dp
3408 END IF
3409 myfmin(1)=min(myfmin(1),fval)
3410 myfmax(1)=max(myfmax(1),fval)
3411 fval=fval*romsscale
3412 myfmin(2)=min(myfmin(2),fval)
3413 myfmax(2)=max(myfmax(2),fval)
3414# ifdef TIME_INTERP
3415 forces(ng)%lrflxG(i,j,tindex)=fval
3416# else
3417 forces(ng)%lrflx(i,j)=fval
3418# endif
3419 END DO
3420 END DO
3421# ifndef TIME_INTERP
3422 IF (localde.eq.localdecount-1) THEN
3423 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3424 CALL exchange_r2d_tile (ng, tile, &
3425 & lbi, ubi, lbj, ubj, &
3426 & forces(ng)%lrflx)
3427 END IF
3428 CALL mp_exchange2d (ng, tile, inlm, 1, &
3429 & lbi, ubi, lbj, ubj, &
3430 & nghostpoints, &
3431 & ewperiodic(ng), nsperiodic(ng), &
3432 & forces(ng)%lrflx)
3433 END IF
3434# endif
3435# endif
3436# if defined BULK_FLUXES && defined LONGWAVE_OUT
3437
3438
3439
3440
3441 CASE ('dlwr', 'dLWrad', 'lwrad_down')
3442 romsscale=tracerfluxscale
3443 ifield=idldwn
3444 gtype=r2dvar
3445 tindex=3-iinfo(8,ifield,ng)
3446 DO j=jstrr,jendr
3447 DO i=istrr,iendr
3448 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3449 fval=scale*ptr2d(i,j)+add_offset
3450 ELSE
3451 fval=0.0_dp
3452 END IF
3453 myfmin(1)=min(myfmin(1),fval)
3454 myfmax(1)=max(myfmax(1),fval)
3455 fval=fval*romsscale
3456 myfmin(2)=min(myfmin(2),fval)
3457 myfmax(2)=max(myfmax(2),fval)
3458# ifdef TIME_INTERP
3459 forces(ng)%lrflxG(i,j,tindex)=fval
3460# else
3461 forces(ng)%lrflx(i,j)=fval
3462# endif
3463 END DO
3464 END DO
3465# ifndef TIME_INTERP
3466 IF (localde.eq.localdecount-1) THEN
3467 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3468 CALL exchange_r2d_tile (ng, tile, &
3469 & lbi, ubi, lbj, ubj, &
3470 & forces(ng)%lrflx)
3471 END IF
3472 CALL mp_exchange2d (ng, tile, inlm, 1, &
3473 & lbi, ubi, lbj, ubj, &
3474 & nghostpoints, &
3475 & ewperiodic(ng), nsperiodic(ng), &
3476 & forces(ng)%lrflx)
3477 END IF
3478# endif
3479# endif
3480# if defined BULK_FLUXES
3481
3482
3483
3484 CASE ('prec', 'rain')
3485 romsscale=scale
3486 ifield=idrain
3487 gtype=r2dvar
3488 tindex=3-iinfo(8,ifield,ng)
3489 DO j=jstrr,jendr
3490 DO i=istrr,iendr
3491 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3492 fval=scale*ptr2d(i,j)+add_offset
3493 ELSE
3494 fval=0.0_dp
3495 END IF
3496 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3497 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3498 myfmin(2)=min(myfmin(2),fval)
3499 myfmax(2)=max(myfmax(2),fval)
3500# ifdef TIME_INTERP
3501 forces(ng)%rainG(i,j,tindex)=fval
3502# else
3503 forces(ng)%rain(i,j)=fval
3504# endif
3505 END DO
3506 END DO
3507# ifndef TIME_INTERP
3508 IF (localde.eq.localdecount-1) THEN
3509 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3510 CALL exchange_r2d_tile (ng, tile, &
3511 & lbi, ubi, lbj, ubj, &
3512 & forces(ng)%rain)
3513 END IF
3514 CALL mp_exchange2d (ng, tile, inlm, 1, &
3515 & lbi, ubi, lbj, ubj, &
3516 & nghostpoints, &
3517 & ewperiodic(ng), nsperiodic(ng), &
3518 & forces(ng)%rain)
3519 END IF
3520# endif
3521# endif
3522# if defined BULK_FLUXES || defined ECOSIM
3523
3524
3525
3526
3527 CASE ('wndu', 'Uwind')
3528 IF (.not.allocated(uwind)) THEN
3529 allocate ( uwind(lbi:ubi,lbj:ubj) )
3530 uwind=missing_dp
3531 END IF
3532 got_wind(1)=.true.
3533 romsscale=scale
3534 ifield=iduair
3535 gtype=r2dvar
3536 tindex=3-iinfo(8,ifield,ng)
3537 DO j=jstrr,jendr
3538 DO i=istrr,iendr
3539 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3540 fval=scale*ptr2d(i,j)+add_offset
3541 ELSE
3542 fval=0.0_dp
3543 END IF
3544 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3545 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3546 myfmin(2)=min(myfmin(2),fval)
3547 myfmax(2)=max(myfmax(2),fval)
3548# ifdef TIME_INTERP
3549 forces(ng)%UwindG(i,j,tindex)=fval
3550# else
3551 uwind(i,j)=fval
3552# endif
3553 END DO
3554 END DO
3555# ifndef TIME_INTERP
3556 IF (localde.eq.localdecount-1) THEN
3557 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3558 CALL exchange_r2d_tile (ng, tile, &
3559 & lbi, ubi, lbj, ubj, &
3560 & uwind)
3561 END IF
3562 CALL mp_exchange2d (ng, tile, inlm, 1, &
3563 & lbi, ubi, lbj, ubj, &
3564 & nghostpoints, &
3565 & ewperiodic(ng), nsperiodic(ng), &
3566 & uwind)
3567 END IF
3568# endif
3569# endif
3570# if defined BULK_FLUXES || defined ECOSIM
3571
3572
3573
3574
3575 CASE ('wndv', 'Vwind')
3576 IF (.not.allocated(vwind)) THEN
3577 allocate ( vwind(lbi:ubi,lbj:ubj) )
3578 vwind=missing_dp
3579 END IF
3580 got_wind(2)=.true.
3581 romsscale=scale
3582 ifield=idvair
3583 gtype=r2dvar
3584 tindex=3-iinfo(8,ifield,ng)
3585 DO j=jstrr,jendr
3586 DO i=istrr,iendr
3587 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3588 fval=scale*ptr2d(i,j)+add_offset
3589 ELSE
3590 fval=0.0_dp
3591 END IF
3592 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3593 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3594 myfmin(2)=min(myfmin(2),fval)
3595 myfmax(2)=max(myfmax(2),fval)
3596# ifdef TIME_INTERP
3597 forces(ng)%VwindG(i,j,tindex)=fval
3598# else
3599 vwind(i,j)=fval
3600# endif
3601 END DO
3602 END DO
3603# ifndef TIME_INTERP
3604 IF (localde.eq.localdecount-1) THEN
3605 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3606 CALL exchange_r2d_tile (ng, tile, &
3607 & lbi, ubi, lbj, ubj, &
3608 & vwind)
3609 END IF
3610 CALL mp_exchange2d (ng, tile, inlm, 1, &
3611 & lbi, ubi, lbj, ubj, &
3612 & nghostpoints, &
3613 & ewperiodic(ng), nsperiodic(ng), &
3614 & vwind)
3615 END IF
3616# endif
3617# endif
3618# if defined SHORTWAVE
3619
3620
3621
3622 CASE ('swrd', 'swrad', 'SWrad', 'SWrad_daily')
3623 romsscale=tracerfluxscale
3624 ifield=idsrad
3625 gtype=r2dvar
3626 tindex=3-iinfo(8,ifield,ng)
3627 DO j=jstrr,jendr
3628 DO i=istrr,iendr
3629 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3630 fval=scale*ptr2d(i,j)+add_offset
3631 ELSE
3632 fval=0.0_dp
3633 END IF
3634 myfmin(1)=min(myfmin(1),fval)
3635 myfmax(1)=max(myfmax(1),fval)
3636 fval=fval*romsscale
3637 myfmin(2)=min(myfmin(2),fval)
3638 myfmax(2)=max(myfmax(2),fval)
3639# ifdef TIME_INTERP
3640 forces(ng)%srflxG(i,j,tindex)=fval
3641# else
3642 forces(ng)%srflx(i,j)=fval
3643# endif
3644 END DO
3645 END DO
3646# ifndef TIME_INTERP
3647 IF (localde.eq.localdecount-1) THEN
3648 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3649 CALL exchange_r2d_tile (ng, tile, &
3650 & lbi, ubi, lbj, ubj, &
3651 & forces(ng)%srflx)
3652 END IF
3653 CALL mp_exchange2d (ng, tile, inlm, 1, &
3654 & lbi, ubi, lbj, ubj, &
3655 & nghostpoints, &
3656 & ewperiodic(ng), nsperiodic(ng), &
3657 & forces(ng)%srflx)
3658 END IF
3659# endif
3660# endif
3661# if !defined BULK_FLUXES
3662
3663
3664
3665
3666
3667 CASE ('lwr', 'LWrad')
3668 romsscale=tracerfluxscale
3669 ifield=idlrad
3670 gtype=r2dvar
3671 tindex=3-iinfo(8,ifield,ng)
3672 DO j=jstrr,jendr
3673 DO i=istrr,iendr
3674 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3675 fval=scale*ptr2d(i,j)+add_offset
3676 ELSE
3677 fval=0.0_dp
3678 END IF
3679 myfmin(1)=min(myfmin(1),fval)
3680 myfmax(1)=max(myfmax(1),fval)
3681 fval=fval*romsscale
3682 myfmin(2)=min(myfmin(2),fval)
3683 myfmax(2)=max(myfmax(2),fval)
3684 forces(ng)%lrflx(i,j)=fval
3685 END DO
3686 END DO
3687
3688
3689
3690
3691
3692 CASE ('dlwr', 'dLWrad', 'lwrad_down')
3693 romsscale=tracerfluxscale
3694 ifield=idldwn
3695 gtype=r2dvar
3696 tindex=3-iinfo(8,ifield,ng)
3697 DO j=jstrr,jendr
3698 DO i=istrr,iendr
3699 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3700 fval=scale*ptr2d(i,j)+add_offset
3701 ELSE
3702 fval=0.0_dp
3703 END IF
3704 myfmin(1)=min(myfmin(1),fval)
3705 myfmax(1)=max(myfmax(1),fval)
3706 fval=fval*romsscale
3707 myfmin(2)=min(myfmin(2),fval)
3708 myfmax(2)=max(myfmax(2),fval)
3709 forces(ng)%lrflx(i,j)=fval
3710 END DO
3711 END DO
3712
3713
3714
3715
3716
3717 CASE ('latent', 'LHfx')
3718 romsscale=tracerfluxscale
3719 gtype=r2dvar
3720 DO j=jstrr,jendr
3721 DO i=istrr,iendr
3722 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3723 fval=scale*ptr2d(i,j)+add_offset
3724 ELSE
3725 fval=0.0_dp
3726 END IF
3727 myfmin(1)=min(myfmin(1),fval)
3728 myfmax(1)=max(myfmax(1),fval)
3729 fval=fval*romsscale
3730 myfmin(2)=min(myfmin(2),fval)
3731 myfmax(2)=max(myfmax(2),fval)
3732 forces(ng)%lhflx(i,j)=fval
3733 END DO
3734 END DO
3735
3736
3737
3738
3739
3740 CASE ('sensible', 'SHfx')
3741 romsscale=tracerfluxscale
3742 gtype=r2dvar
3743 DO j=jstrr,jendr
3744 DO i=istrr,iendr
3745 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3746 fval=scale*ptr2d(i,j)+add_offset
3747 ELSE
3748 fval=0.0_dp
3749 END IF
3750 myfmin(1)=min(myfmin(1),fval)
3751 myfmax(1)=max(myfmax(1),fval)
3752 fval=fval*romsscale
3753 myfmin(2)=min(myfmin(2),fval)
3754 myfmax(2)=max(myfmax(2),fval)
3755 forces(ng)%shflx(i,j)=fval
3756 END DO
3757 END DO
3758
3759
3760
3761 CASE ('nflx', 'shflux')
3762 romsscale=tracerfluxscale
3763 ifield=idtsur(itemp)
3764 gtype=r2dvar
3765 tindex=3-iinfo(8,ifield,ng)
3766 DO j=jstrr,jendr
3767 DO i=istrr,iendr
3768 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3769 fval=scale*ptr2d(i,j)+add_offset
3770 ELSE
3771 fval=0.0_dp
3772 END IF
3773 myfmin(1)=min(myfmin(1),fval)
3774 myfmax(1)=max(myfmax(1),fval)
3775 fval=fval*romsscale
3776 myfmin(2)=min(myfmin(2),fval)
3777 myfmax(2)=max(myfmax(2),fval)
3778# ifdef TIME_INTERP
3779 forces(ng)%stfluxG(i,j,tindex,itemp)=fval
3780# else
3781 forces(ng)%stflux(i,j,itemp)=fval
3782# endif
3783 END DO
3784 END DO
3785# ifndef TIME_INTERP
3786 IF (localde.eq.localdecount-1) THEN
3787 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3788 CALL exchange_r2d_tile (ng, tile, &
3789 & lbi, ubi, lbj, ubj, &
3790 & forces(ng)%stflux(:,:,itemp))
3791 END IF
3792 CALL mp_exchange2d (ng, tile, inlm, 1, &
3793 & lbi, ubi, lbj, ubj, &
3794 & nghostpoints, &
3795 & ewperiodic(ng), nsperiodic(ng), &
3796 & forces(ng)%stflux(:,:,itemp))
3797 END IF
3798# endif
3799# endif
3800# if !defined BULK_FLUXES && defined SALINITY
3801
3802
3803
3804 CASE ('sflx', 'swflux')
3805 romsscale=freshwaterscale
3806 ifield=idtsur(isalt)
3807 gtype=r2dvar
3808 tindex=3-iinfo(8,ifield,ng)
3809 DO j=jstrr,jendr
3810 DO i=istrr,iendr
3811 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3812 fval=scale*ptr2d(i,j)+add_offset
3813 ELSE
3814 fval=0.0_dp
3815 END IF
3816 myfmin(1)=min(myfmin(1),fval)
3817 myfmax(1)=max(myfmax(1),fval)
3818 fval=fval*romsscale
3819 myfmin(2)=min(myfmin(2),fval)
3820 myfmax(2)=max(myfmax(2),fval)
3821# ifdef TIME_INTERP
3822 forces(ng)%stfluxG(i,j,tindex,isalt)=fval
3823# else
3824 forces(ng)%stflux(i,j,isalt)=fval
3825# endif
3826 END DO
3827 END DO
3828# ifndef TIME_INTERP
3829 IF (localde.eq.localdecount-1) THEN
3830 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3831 CALL exchange_r2d_tile (ng, tile, &
3832 & lbi, ubi, lbj, ubj, &
3833 & forces(ng)%stflux(:,:,isalt))
3834 END IF
3835 CALL mp_exchange2d (ng, tile, inlm, 1, &
3836 & lbi, ubi, lbj, ubj, &
3837 & nghostpoints, &
3838 & ewperiodic(ng), nsperiodic(ng), &
3839 & forces(ng)%stflux(:,:,isalt))
3840 END IF
3841# endif
3842# endif
3843# if !defined BULK_FLUXES
3844
3845
3846
3847
3848 CASE ('taux', 'sustr')
3849 IF (.not.allocated(ustress)) THEN
3850 allocate ( ustress(lbi:ubi,lbj:ubj) )
3851 ustress=missing_dp
3852 END IF
3853 got_stress(1)=.true.
3854 romsscale=stressscale
3855 ifield=idusms
3856 gtype=u2dvar
3857 tindex=3-iinfo(8,ifield,ng)
3858 DO j=jstrr,jendr
3859 DO i=istrr,iendr
3860 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3861 fval=scale*ptr2d(i,j)+add_offset
3862 ELSE
3863 fval=0.0_dp
3864 END IF
3865 myfmin(1)=min(myfmin(1),fval)
3866 myfmax(1)=max(myfmax(1),fval)
3867 fval=fval*romsscale
3868 myfmin(2)=min(myfmin(2),fval)
3869 myfmax(2)=max(myfmax(2),fval)
3870# ifdef TIME_INTERP
3871 forces(ng)%sustrG(i,j,tindex)=fval
3872# else
3873 ustress(i,j)=fval
3874# endif
3875 END DO
3876 END DO
3877 IF (localde.eq.localdecount-1) THEN
3878 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3879 CALL exchange_r2d_tile (ng, tile, &
3880 & lbi, ubi, lbj, ubj, &
3881 & ustress)
3882 END IF
3883 CALL mp_exchange2d (ng, tile, inlm, 1, &
3884 & lbi, ubi, lbj, ubj, &
3885 & nghostpoints, &
3886 & ewperiodic(ng), nsperiodic(ng), &
3887 & ustress)
3888 END IF
3889# endif
3890# if !defined BULK_FLUXES
3891
3892
3893
3894
3895 CASE ('tauy', 'svstr')
3896 IF (.not.allocated(vstress)) THEN
3897 allocate ( vstress(lbi:ubi,lbj:ubj) )
3898 vstress=missing_dp
3899 END IF
3900 got_stress(2)=.true.
3901 romsscale=stressscale
3902 ifield=idvsms
3903 gtype=v2dvar
3904 tindex=3-iinfo(8,ifield,ng)
3905 DO j=jstrr,jendr
3906 DO i=istrr,iendr
3907 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3908 fval=scale*ptr2d(i,j)+add_offset
3909 ELSE
3910 fval=0.0_dp
3911 END IF
3912 myfmin(1)=min(myfmin(1),fval)
3913 myfmax(1)=max(myfmax(1),fval)
3914 fval=fval*romsscale
3915 myfmin(2)=min(myfmin(2),fval)
3916 myfmax(2)=max(myfmax(2),fval)
3917# ifdef TIME_INTERP
3918 forces(ng)%svstrG(i,j,tindex)=fval
3919# else
3920 vstress(i,j)=fval
3921# endif
3922 END DO
3923 END DO
3924 IF (localde.eq.localdecount-1) THEN
3925 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3926 CALL exchange_r2d_tile (ng, tile, &
3927 & lbi, ubi, lbj, ubj, &
3928 & vstress)
3929 END IF
3930 CALL mp_exchange2d (ng, tile, inlm, 1, &
3931 & lbi, ubi, lbj, ubj, &
3932 & nghostpoints, &
3933 & ewperiodic(ng), nsperiodic(ng), &
3934 & vstress)
3935 END IF
3936# endif
3937# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
3938
3939
3940
3941 CASE ('RhoAir')
3942 IF (.not.allocated(rhoair)) THEN
3943 allocate ( rhoair(lbi:ubi,lbj:ubj) )
3944 rhoair=missing_dp
3945 END IF
3946 got_rhoair=.true.
3947 romsscale=scale
3948 DO j=jstrr,jendr
3949 DO i=istrr,iendr
3950 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3951 fval=scale*ptr2d(i,j)+add_offset
3952 ELSE
3953 fval=0.0_dp
3954 END IF
3955 myfmin(1)=min(myfmin(1),fval)
3956 myfmax(1)=max(myfmax(1),fval)
3957 fval=fval*romsscale
3958 myfmin(2)=min(myfmin(2),fval)
3959 myfmax(2)=max(myfmax(2),fval)
3960 rhoair(i,j)=fval
3961 END DO
3962 END DO
3963 IF (localde.eq.localdecount-1) THEN
3964 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
3965 CALL exchange_r2d_tile (ng, tile, &
3966 & lbi, ubi, lbj, ubj, &
3967 & rhoair)
3968 END IF
3969 CALL mp_exchange2d (ng, tile, inlm, 1, &
3970 & lbi, ubi, lbj, ubj, &
3971 & nghostpoints, &
3972 & ewperiodic(ng), nsperiodic(ng), &
3973 & rhoair)
3974 END IF
3975
3976
3977
3978
3979 CASE ('Uwind_sbl')
3980 IF (.not.allocated(xwind)) THEN
3981 allocate ( xwind(lbi:ubi,lbj:ubj) )
3982 xwind=missing_dp
3983 END IF
3984 got_wind_sbl(1)=.true.
3985 romsscale=scale
3986 DO j=jstrr,jendr
3987 DO i=istrr,iendr
3988 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
3989 fval=scale*ptr2d(i,j)+add_offset
3990 ELSE
3991 fval=0.0_dp
3992 END IF
3993 myfmin(1)=min(myfmin(1),ptr2d(i,j))
3994 myfmax(1)=max(myfmax(1),ptr2d(i,j))
3995 fval=fval*romsscale
3996 myfmin(2)=min(myfmin(2),fval)
3997 myfmax(2)=max(myfmax(2),fval)
3998 xwind(i,j)=fval
3999 END DO
4000 END DO
4001 IF (localde.eq.localdecount-1) THEN
4002 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
4003 CALL exchange_r2d_tile (ng, tile, &
4004 & lbi, ubi, lbj, ubj, &
4005 & xwind)
4006 END IF
4007 CALL mp_exchange2d (ng, tile, inlm, 1, &
4008 & lbi, ubi, lbj, ubj, &
4009 & nghostpoints, &
4010 & ewperiodic(ng), nsperiodic(ng), &
4011 & xwind)
4012 END IF
4013
4014
4015
4016
4017 CASE ('Vwind_sbl')
4018 IF (.not.allocated(ywind)) THEN
4019 allocate ( ywind(lbi:ubi,lbj:ubj) )
4020 ywind=missing_dp
4021 END IF
4022 got_wind_sbl(2)=.true.
4023 romsscale=scale
4024 DO j=jstrr,jendr
4025 DO i=istrr,iendr
4026 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
4027 fval=scale*ptr2d(i,j)+add_offset
4028 ELSE
4029 fval=0.0_dp
4030 END IF
4031 myfmin(1)=min(myfmin(1),ptr2d(i,j))
4032 myfmax(1)=max(myfmax(1),ptr2d(i,j))
4033 fval=fval*romsscale
4034 myfmin(2)=min(myfmin(2),fval)
4035 myfmax(2)=max(myfmax(2),fval)
4036 ywind(i,j)=fval
4037 END DO
4038 END DO
4039 IF (localde.eq.localdecount-1) THEN
4040 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
4041 CALL exchange_r2d_tile (ng, tile, &
4042 & lbi, ubi, lbj, ubj, &
4043 & ywind)
4044 END IF
4045 CALL mp_exchange2d (ng, tile, inlm, 1, &
4046 & lbi, ubi, lbj, ubj, &
4047 & nghostpoints, &
4048 & ewperiodic(ng), nsperiodic(ng), &
4049 & ywind)
4050 END IF
4051
4052
4053
4054
4055 CASE ('Wstar')
4056 IF (.not.allocated(wstar)) THEN
4057 allocate ( wstar(lbi:ubi,lbj:ubj) )
4058 wstar=missing_dp
4059 END IF
4060 got_wstar=.true.
4061 romsscale=scale
4062 DO j=jstrr,jendr
4063 DO i=istrr,iendr
4064 IF (abs(ptr2d(i,j)).lt.tol_dp) THEN
4065 fval=scale*ptr2d(i,j)+add_offset
4066 ELSE
4067 fval=0.0_dp
4068 END IF
4069 myfmin(1)=min(myfmin(1),ptr2d(i,j))
4070 myfmax(1)=max(myfmax(1),ptr2d(i,j))
4071 fval=fval*romsscale
4072 myfmin(2)=min(myfmin(2),fval)
4073 myfmax(2)=max(myfmax(2),fval)
4074 wstar(i,j)=fval
4075 END DO
4076 END DO
4077 IF (localde.eq.localdecount-1) THEN
4078 IF (ewperiodic(ng).or.nsperiodic(ng)) THEN
4079 CALL exchange_r2d_tile (ng, tile, &
4080 & lbi, ubi, lbj, ubj, &
4081 & wstar)
4082 END IF
4083 CALL mp_exchange2d (ng, tile, inlm, 1, &
4084 & lbi, ubi, lbj, ubj, &
4085 & nghostpoints, &
4086 & ewperiodic(ng), nsperiodic(ng), &
4087 & wstar)
4088 END IF
4089# endif
4090
4091
4092
4093 CASE DEFAULT
4094 IF (localpet.eq.0) THEN
4095 WRITE (cplout,10) trim(importnamelist(ifld)), &
4096 & trim(time_currentstring), &
4097 & trim(cinpname)
4098 END IF
4099 exit_flag=9
4100 IF (founderror(exit_flag, noerror, __line__, &
4101 & myfile)) THEN
4102 rc=esmf_rc_not_found
4103 RETURN
4104 END IF
4105 END SELECT
4106
4107
4108
4109 IF (debuglevel.eq.4) THEN
4110 WRITE (cplout,20) localpet, localde, &
4111 & lbound(ptr2d,dim=1), ubound(ptr2d,dim=1), &
4112 & lbound(ptr2d,dim=2), ubound(ptr2d,dim=2), &
4113 & istrr, iendr, jstrr, jendr
4114 END IF
4115
4116
4117
4118
4119 IF (associated(ptr2d)) nullify (ptr2d)
4120 END DO de_loop
4121
4122
4123
4124 CALL esmf_vmallreduce (vm, &
4125 & senddata=myfmin, &
4126 & recvdata=fmin, &
4127 & count=2, &
4128 & reduceflag=esmf_reduce_min, &
4129 & rc=rc)
4130 IF (esmf_logfounderror(rctocheck=rc, &
4131 & msg=esmf_logerr_passthru, &
4132 & line=__line__, &
4133 & file=myfile)) THEN
4134 RETURN
4135 END IF
4136
4137 CALL esmf_vmallreduce (vm, &
4138 & senddata=myfmax, &
4139 & recvdata=fmax, &
4140 & count=2, &
4141 & reduceflag=esmf_reduce_max, &
4142 & rc=rc)
4143 IF (esmf_logfounderror(rctocheck=rc, &
4144 & msg=esmf_logerr_passthru, &
4145 & line=__line__, &
4146 & file=myfile)) THEN
4147 RETURN
4148 END IF
4149
4150
4151
4152 IF ((debuglevel.ge.0).and.(localpet.eq.0)) THEN
4153 WRITE (cplout,30) trim(importnamelist(ifld)), &
4154# ifdef TIME_INTERP
4155 & trim(mydate(tindex)), ng, &
4156 & fmin(1), fmax(1), tindex
4157# else
4158 & trim(time_currentstring), ng, &
4159 & fmin(1), fmax(1)
4160# endif
4161 IF (romsscale.ne.1.0_dp) THEN
4162 WRITE (cplout,40) fmin(2), fmax(2), &
4163 & ' romsScale = ', romsscale
4164 ELSE IF (add_offset.ne.0.0_dp) THEN
4165 WRITE (cplout,40) fmin(2), fmax(2), &
4166 & ' AddOffset = ', add_offset
4167 END IF
4168 END IF
4169
4170# ifdef TIME_INTERP
4171
4172
4173
4174
4175 IF (loadit) THEN
4176 linfo(1,ifield,ng)=.true.
4177 linfo(3,ifield,ng)=.false.
4178 iinfo(1,ifield,ng)=gtype
4179 iinfo(8,ifield,ng)=tindex
4180 finfo(1,ifield,ng)=tmin
4181 finfo(2,ifield,ng)=tmax
4182 finfo(3,ifield,ng)=tstr
4183 finfo(4,ifield,ng)=tend
4184 finfo(8,ifield,ng)=fmin(1)
4185 finfo(9,ifield,ng)=fmax(1)
4186 vtime(tindex,ifield,ng)=myvtime(tindex)
4187 tintrp(tindex,ifield,ng)=mytintrp(tindex)*86400.0_dp
4188 END IF
4189# endif
4190
4191
4192
4193 IF ((debuglevel.ge.3).and. &
4194 & models(iroms)%ImportField(id)%debug_write) THEN
4195 WRITE (ofile,50) ng, trim(importnamelist(ifld)), &
4196 & year, month, day, hour, minutes, seconds
4197 CALL esmf_fieldwrite (field, &
4198 & trim(ofile), &
4199 & overwrite=.true., &
4200 & rc=rc)
4201 IF (esmf_logfounderror(rctocheck=rc, &
4202 & msg=esmf_logerr_passthru, &
4203 & line=__line__, &
4204 & file=myfile)) THEN
4205 RETURN
4206 END IF
4207 END IF
4208
4209 END DO fld_loop
4210
4211# if defined BULK_FLUXES || defined ECOSIM
4212
4213
4214
4215 IF (got_wind(1).and.got_wind(2)) THEN
4216 CALL roms_rotate (ng, tile, geo2grid_rho, &
4217 & lbi, ubi, lbj, ubj, &
4218 & uwind, vwind, &
4219 & forces(ng)%Uwind, forces(ng)%Vwind)
4220 deallocate (uwind)
4221 deallocate (vwind)
4222 END IF
4223# endif
4224# if !defined BULK_FLUXES
4225
4226
4227
4228
4229 IF (got_stress(1).and.got_stress(2)) THEN
4230 CALL roms_rotate (ng, tile, geo2grid, &
4231 & lbi, ubi, lbj, ubj, &
4232 & ustress, vstress, &
4233 & forces(ng)%sustr, forces(ng)%svstr)
4234 deallocate (ustress)
4235 deallocate (vstress)
4236 END IF
4237# endif
4238# if defined WIND_MINUS_CURRENT && !defined BULK_FLUXES
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254 myfmin= missing_dp
4255 myfmax=-missing_dp
4256
4257 IF (got_rhoair.and.got_wstar.and. &
4258 & got_wind_sbl(1).and.got_wind_sbl(2)) THEN
4259 IF (.not.allocated(uwrk)) THEN
4260 allocate ( uwrk(lbi:ubi,lbj:ubj) )
4261 uwrk=missing_dp
4262 END IF
4263 IF (.not.allocated(vwrk)) THEN
4264 allocate ( vwrk(lbi:ubi,lbj:ubj) )
4265 vwrk=missing_dp
4266 END IF
4267
4268 CALL roms_rotate (ng, tile, grid2geo_rho, &
4269 & lbi, ubi, lbj, ubj, &
4270 & ocean(ng)%u(:,:,n(ng),nstp(ng)), &
4271 & ocean(ng)%v(:,:,n(ng),nstp(ng)), &
4272 & uwrk, vwrk)
4273
4274 DO j=jstr-1,jend+1
4275 DO i=istr-1,iend+1
4276 romsscale=stressscale
4277 urel=xwind(i,j)-uwrk(i,j)
4278 vrel=ywind(i,j)-vwrk(i,j)
4279 wmag=sqrt(xwind(i,j)*xwind(i,j)+ &
4280 & ywind(i,j)*ywind(i,j))
4281 wrel=sqrt(urel*urel+vrel*vrel)
4282 cff1=romsscale*rhoair(i,j)
4283 cff2=wstar(i,j)*wstar(i,j)/(wmag*wmag+eps)
4284 cff3=cff1*cff2*wrel
4285 uwrk(i,j)=cff3*urel
4286 vwrk(i,j)=cff3*vrel
4287 myfmin(1)=min(myfmin(1),uwrk(i,j))
4288 myfmin(2)=min(myfmin(2),vwrk(i,j))
4289 myfmax(1)=max(myfmax(1),uwrk(i,j))
4290 myfmax(2)=max(myfmax(2),vwrk(i,j))
4291 END DO
4292 END DO
4293 deallocate (rhoair)
4294 deallocate (wstar)
4295 deallocate (xwind)
4296 deallocate (ywind)
4297
4298 CALL roms_rotate (ng, tile, geo2grid, &
4299 & lbi, ubi, lbj, ubj, &
4300 & uwrk, vwrk, &
4301 & forces(ng)%sustr, &
4302 & forces(ng)%svstr)
4303 deallocate (uwrk)
4304 deallocate (vwrk)
4305
4306
4307
4308 IF (debuglevel.ge.0) THEN
4309 CALL esmf_vmallreduce (vm, &
4310 & senddata=myfmin, &
4311 & recvdata=fmin, &
4312 & count=2, &
4313 & reduceflag=esmf_reduce_min, &
4314 & rc=rc)
4315 IF (esmf_logfounderror(rctocheck=rc, &
4316 & msg=esmf_logerr_passthru, &
4317 & line=__line__, &
4318 & file=myfile)) THEN
4319 RETURN
4320 END IF
4321
4322 CALL esmf_vmallreduce (vm, &
4323 & senddata=myfmax, &
4324 & recvdata=fmax, &
4325 & count=2, &
4326 & reduceflag=esmf_reduce_max, &
4327 & rc=rc)
4328 IF (esmf_logfounderror(rctocheck=rc, &
4329 & msg=esmf_logerr_passthru, &
4330 & line=__line__, &
4331 & file=myfile)) THEN
4332 RETURN
4333 END IF
4334
4335 IF (localpet.eq.0) THEN
4336 WRITE (cplout,60) 'sustr', &
4337 & trim(time_currentstring), ng, &
4338 & fmin(1)/stressscale, &
4339 & fmax(1)/stressscale
4340 WRITE (cplout,40) fmin(1), fmax(1), &
4341 & ' romsScale = ', stressscale
4342
4343 WRITE (cplout,60) 'svstr', &
4344 & trim(time_currentstring), ng, &
4345 & fmin(2)/stressscale, &
4346 & fmax(2)/stressscale
4347 WRITE (cplout,40) fmin(2), fmax(2), &
4348 & ' romsScale = ', stressscale
4349 END IF
4350 END IF
4351 END IF
4352# endif
4353
4354
4355
4356 IF (allocated(importnamelist)) deallocate (importnamelist)
4357
4358
4359
4360 IF (importcount.gt.0) THEN
4361 models(iroms)%ImportCalls=models(iroms)%ImportCalls+1
4362 END IF
4363
4364 IF (esm_track) THEN
4365 WRITE (trac,'(a,a,i0)') '<== Exiting ROMS_Import', &
4366 & ', PET', petrank
4367 FLUSH (trac)
4368 END IF
4369 IF (debuglevel.gt.0) FLUSH (cplout)
4370
4371 10 FORMAT (/,3x,' ROMS_Import - unable to find option to import: ', &
4372 & a,t72,a,/,18x,'check ''Import(roms)'' in input script: ', &
4373 & a)
4374 20 FORMAT (18x,'PET/DE [',i3.3,'/',i2.2,'], Pointer Size: ',4i8, &
4375 & /,36x,'Tiling Range: ',4i8)
4376 30 FORMAT (3x,' ROMS_Import - ESMF: importing field ''',a,'''', &
4377 & t72,a,2x,'Grid ',i2.2, &
4378# ifdef TIME_INTERP
4379 & /,19x,'(InpMin = ', 1p,e15.8,0p,' InpMax = ',1p,e15.8,0p, &
4380 & ' SnapshotIndex = ',i1,')')
4381# else
4382 & /,19x,'(InpMin = ', 1p,e15.8,0p,' InpMax = ',1p,e15.8,0p, &
4383 & ')')
4384# endif
4385 40 FORMAT (19x,'(OutMin = ', 1p,e15.8,0p,' OutMax = ',1p,e15.8,0p, &
4386 & 1x,a,1p,e15.8,0p,')')
4387 50 FORMAT ('roms_',i2.2,'_import_',a,'_',i4.4,2('-',i2.2),'_', &
4388 & i2.2,2('.',i2.2),'.nc')
4389 60 FORMAT (3x,' ROMS_Import - ESMF: computing field ''',a,'''', &
4390 & t72,a,2x,'Grid ',i2.2, &
4391 & /,19x,'(InpMin = ', 1p,e15.8,0p,' InpMax = ',1p,e15.8,0p, &
4392 & ')')
4393
4394 RETURN