Ignore:
Timestamp:
Sep 20, 2022, 4:09:49 PM (22 months ago)
Author:
lguez
Message:

Replace nf_get_vara_type by nf90_get_var

The immediate motivation is a bug fix: nf_get_vara_type was called
with scalar instead of array actual arguments for dummy array
arguments start and count. Correcting this, we might as well take the
opportunity to use nf90_get_var, so we no longer need to test
NC_DOUBLE and we have half as many calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/read_pstoke.F90

    r2345 r4254  
    252252
    253253    ! niveaux de pression
    254 #ifdef NC_DOUBLE
    255     status = nf_get_vara_double(ncidp, varidpl, 1, zklevo, pl)
    256 #else
    257     status = nf_get_vara_real(ncidp, varidpl, 1, zklevo, pl)
    258 #endif
     254    status = nf90_get_var(ncidp, varidpl, pl, [1], [zklevo])
    259255
    260256    ! lecture de aire et phis
     
    271267
    272268    ! phis
    273 #ifdef NC_DOUBLE
    274     status = nf_get_vara_double(ncidp, varidps, start, count, phisfi2)
    275 #else
    276     status = nf_get_vara_real(ncidp, varidps, start, count, phisfi2)
    277 #endif
     269    status = nf90_get_var(ncidp, varidps, phisfi2, start, count)
    278270    CALL gr_ecrit_fi(1, klono, imo, jmo+1, phisfi2, phisfi)
    279271
    280272    ! aire
    281 #ifdef NC_DOUBLE
    282     status = nf_get_vara_double(ncidp, varidai, start, count, airefi2)
    283 #else
    284     status = nf_get_vara_real(ncidp, varidai, start, count, airefi2)
    285 #endif
     273    status = nf90_get_var(ncidp, varidai, airefi2, start, count)
    286274    CALL gr_ecrit_fi(1, klono, imo, jmo+1, airefi2, airefi)
    287275  ELSE
     
    309297    ! *** Lessivage******************************************************
    310298    ! frac_impa
    311 #ifdef NC_DOUBLE
    312     status = nf_get_vara_double(ncidp, varidfi, start, count, frac_impa2)
    313 #else
    314     status = nf_get_vara_real(ncidp, varidfi, start, count, frac_impa2)
    315 #endif
     299    status = nf90_get_var(ncidp, varidfi, frac_impa2, start, count)
    316300    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, frac_impa2, frac_impa)
    317301
    318302    ! frac_nucl
    319 #ifdef NC_DOUBLE
    320     status = nf_get_vara_double(ncidp, varidfn, start, count, frac_nucl2)
    321 #else
    322     status = nf_get_vara_real(ncidp, varidfn, start, count, frac_nucl2)
    323 #endif
     303    status = nf90_get_var(ncidp, varidfn, frac_nucl2, start, count)
    324304    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, frac_nucl2, frac_nucl)
    325305
    326306    ! *** Temperature ******************************************************
    327307    ! abder t
    328 #ifdef NC_DOUBLE
    329     status = nf_get_vara_double(ncidp, varidt, start, count, t2)
    330 #else
    331     status = nf_get_vara_real(ncidp, varidt, start, count, t2)
    332 #endif
     308    status = nf90_get_var(ncidp, varidt, t2, start, count)
    333309    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, t2, t)
    334310
    335311    ! *** Flux pour le calcul de la convection TIEDTK ***********************
    336312    ! mfu
    337 #ifdef NC_DOUBLE
    338     status = nf_get_vara_double(ncidp, varidmfu, start, count, mfu2)
    339 #else
    340     status = nf_get_vara_real(ncidp, varidmfu, start, count, mfu2)
    341 #endif
     313    status = nf90_get_var(ncidp, varidmfu, mfu2, start, count)
    342314    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, mfu2, mfu)
    343315
    344316    ! mfd
    345 #ifdef NC_DOUBLE
    346     status = nf_get_vara_double(ncidp, varidmfd, start, count, mfd2)
    347 #else
    348     status = nf_get_vara_real(ncidp, varidmfd, start, count, mfd2)
    349 #endif
     317    status = nf90_get_var(ncidp, varidmfd, mfd2, start, count)
    350318    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, mfd2, mfd)
    351319
    352320    ! en_u
    353 #ifdef NC_DOUBLE
    354     status = nf_get_vara_double(ncidp, varidenu, start, count, en_u2)
    355 #else
    356     status = nf_get_vara_real(ncidp, varidenu, start, count, en_u2)
    357 #endif
     321    status = nf90_get_var(ncidp, varidenu, en_u2, start, count)
    358322    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_u2, en_u)
    359323
    360324    ! de_u
    361 #ifdef NC_DOUBLE
    362     status = nf_get_vara_double(ncidp, variddeu, start, count, de_u2)
    363 #else
    364     status = nf_get_vara_real(ncidp, variddeu, start, count, de_u2)
    365 #endif
     325    status = nf90_get_var(ncidp, variddeu, de_u2, start, count)
    366326    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, de_u2, de_u)
    367327
    368328    ! en_d
    369 #ifdef NC_DOUBLE
    370     status = nf_get_vara_double(ncidp, varidend, start, count, en_d2)
    371 #else
    372     status = nf_get_vara_real(ncidp, varidend, start, count, en_d2)
    373 #endif
     329    status = nf90_get_var(ncidp, varidend, en_d2, start, count)
    374330    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_d2, en_d)
    375331
    376332    ! de_d
    377 #ifdef NC_DOUBLE
    378     status = nf_get_vara_double(ncidp, varidded, start, count, de_d2)
    379 #else
    380     status = nf_get_vara_real(ncidp, varidded, start, count, de_d2)
    381 #endif
     333    status = nf90_get_var(ncidp, varidded, de_d2, start, count)
    382334    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, de_d2, de_d)
    383335
     
    385337    ! turbulent**********************************
    386338    ! coefh
    387 #ifdef NC_DOUBLE
    388     status = nf_get_vara_double(ncidp, varidch, start, count, coefh2)
    389 #else
    390     status = nf_get_vara_real(ncidp, varidch, start, count, coefh2)
    391 #endif
     339    status = nf90_get_var(ncidp, varidch, coefh2, start, count)
    392340    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, coefh2, coefh)
    393341
     
    395343    ! Thermiques************************
    396344    ! abder thermiques
    397 #ifdef NC_DOUBLE
    398     status = nf_get_vara_double(ncidp, varidfmth, start, count, fm_therm2)
    399 #else
    400     status = nf_get_vara_real(ncidp, varidfmth, start, count, fm_therm2)
    401 #endif
     345    status = nf90_get_var(ncidp, varidfmth, fm_therm2, start, count)
    402346    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, fm_therm2, fm_therm)
    403347
    404 #ifdef NC_DOUBLE
    405     status = nf_get_vara_double(ncidp, varidenth, start, count, en_therm2)
    406 #else
    407     status = nf_get_vara_real(ncidp, varidenth, start, count, en_therm2)
    408 #endif
     348    status = nf90_get_var(ncidp, varidenth, en_therm2, start, count)
    409349    CALL gr_ecrit_fi(klevo, klono, imo, jmo+1, en_therm2, en_therm)
    410350
     
    416356    count(4) = 0
    417357    ! pyu1
    418 #ifdef NC_DOUBLE
    419     status = nf_get_vara_double(ncidp, varidyu1, start, count, pyu12)
    420 #else
    421     status = nf_get_vara_real(ncidp, varidyu1, start, count, pyu12)
    422 #endif
     358    status = nf90_get_var(ncidp, varidyu1, pyu12, start, count)
    423359    CALL gr_ecrit_fi(1, klono, imo, jmo+1, pyu12, pyu1)
    424360
    425361    ! pyv1
    426 #ifdef NC_DOUBLE
    427     status = nf_get_vara_double(ncidp, varidyv1, start, count, pyv12)
    428 #else
    429     status = nf_get_vara_real(ncidp, varidyv1, start, count, pyv12)
    430 #endif
     362    status = nf90_get_var(ncidp, varidyv1, pyv12, start, count)
    431363    CALL gr_ecrit_fi(1, klono, imo, jmo+1, pyv12, pyv1)
    432364
    433365    ! *** Temperature au sol ********************************************
    434366    ! ftsol1
    435 #ifdef NC_DOUBLE
    436     status = nf_get_vara_double(ncidp, varidfts1, start, count, ftsol12)
    437 #else
    438     status = nf_get_vara_real(ncidp, varidfts1, start, count, ftsol12)
    439 #endif
     367    status = nf90_get_var(ncidp, varidfts1, ftsol12, start, count)
    440368    CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol12, ftsol1)
    441369
    442370    ! ftsol2
    443 #ifdef NC_DOUBLE
    444     status = nf_get_vara_double(ncidp, varidfts2, start, count, ftsol22)
    445 #else
    446     status = nf_get_vara_real(ncidp, varidfts2, start, count, ftsol22)
    447 #endif
     371    status = nf90_get_var(ncidp, varidfts2, ftsol22, start, count)
    448372    CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol22, ftsol2)
    449373
    450374    ! ftsol3
    451 #ifdef NC_DOUBLE
    452     status = nf_get_vara_double(ncidp, varidfts3, start, count, ftsol32)
    453 #else
    454     status = nf_get_vara_real(ncidp, varidfts3, start, count, ftsol32)
    455 #endif
     375    status = nf90_get_var(ncidp, varidfts3, ftsol32, start, count)
    456376    CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol32, ftsol3)
    457377
    458378    ! ftsol4
    459 #ifdef NC_DOUBLE
    460     status = nf_get_vara_double(ncidp, varidfts4, start, count, ftsol42)
    461 #else
    462     status = nf_get_vara_real(ncidp, varidfts4, start, count, ftsol42)
    463 #endif
     379    status = nf90_get_var(ncidp, varidfts4, ftsol42, start, count)
    464380    CALL gr_ecrit_fi(1, klono, imo, jmo+1, ftsol42, ftsol4)
    465381
    466382    ! *** Nature du sol **************************************************
    467383    ! psrf1
    468 #ifdef NC_DOUBLE
    469     status = nf_get_vara_double(ncidp, varidpsr1, start, count, psrf12)
    470 #else
    471     status = nf_get_vara_real(ncidp, varidpsr1, start, count, psrf12)
    472 #endif
     384    status = nf90_get_var(ncidp, varidpsr1, psrf12, start, count)
    473385    CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf12, psrf1)
    474386
    475387    ! psrf2
    476 #ifdef NC_DOUBLE
    477     status = nf_get_vara_double(ncidp, varidpsr2, start, count, psrf22)
    478 #else
    479     status = nf_get_vara_real(ncidp, varidpsr2, start, count, psrf22)
    480 #endif
     388    status = nf90_get_var(ncidp, varidpsr2, psrf22, start, count)
    481389    CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf22, psrf2)
    482390
    483391    ! psrf3
    484 #ifdef NC_DOUBLE
    485     status = nf_get_vara_double(ncidp, varidpsr3, start, count, psrf32)
    486 #else
    487     status = nf_get_vara_real(ncidp, varidpsr3, start, count, psrf32)
    488 #endif
     392    status = nf90_get_var(ncidp, varidpsr3, psrf32, start, count)
    489393    CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf32, psrf3)
    490394
    491395    ! psrf4
    492 #ifdef NC_DOUBLE
    493     status = nf_get_vara_double(ncidp, varidpsr4, start, count, psrf42)
    494 #else
    495     status = nf_get_vara_real(ncidp, varidpsr4, start, count, psrf42)
    496 #endif
     396    status = nf90_get_var(ncidp, varidpsr4, psrf42, start, count)
    497397    CALL gr_ecrit_fi(1, klono, imo, jmo+1, psrf42, psrf4)
    498398
Note: See TracChangeset for help on using the changeset viewer.