Changeset 3552 for trunk/LMDZ.GENERIC/libf/phystd/iostart.F90
- Timestamp:
- Dec 13, 2024, 5:17:13 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.GENERIC/libf/phystd/iostart.F90
r3515 r3552 4 4 PRIVATE 5 5 INTEGER,SAVE :: nid_start ! NetCDF file identifier for startfi.nc file 6 INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file6 ! INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file 7 7 !$OMP THREADPRIVATE(nid_start,nid_restart) 8 8 … … 49 49 CONTAINS 50 50 51 SUBROUTINE open_startphy(filename )51 SUBROUTINE open_startphy(filename,nid_start) 52 52 USE netcdf, only: NF90_OPEN, NF90_NOERR, NF90_NOWRITE, nf90_strerror 53 53 USE mod_phys_lmdz_para, only: is_master, bcast 54 54 IMPLICIT NONE 55 CHARACTER(LEN=*) :: filename 56 INTEGER :: ierr 55 CHARACTER(LEN=*) :: filename 56 INTEGER,INTENT(INOUT) :: nid_start 57 INTEGER :: ierr 57 58 58 59 IF (is_master) THEN … … 69 70 END SUBROUTINE open_startphy 70 71 71 SUBROUTINE close_startphy 72 SUBROUTINE close_startphy(nid_start) 72 73 USE netcdf, only: NF90_CLOSE 73 74 USE mod_phys_lmdz_para, only: is_master 74 75 IMPLICIT NONE 75 INTEGER :: ierr 76 INTEGER,INTENT(IN) :: nid_start 77 INTEGER :: ierr 76 78 77 79 IF (is_master) THEN … … 82 84 83 85 84 FUNCTION inquire_field( Field_name)86 FUNCTION inquire_field(nid_start,Field_name) 85 87 ! check if a given field is present in the input file 86 88 USE netcdf, only: NF90_INQ_VARID, NF90_NOERR 87 89 USE mod_phys_lmdz_para, only: is_master, bcast 88 90 IMPLICIT NONE 91 INTEGER,INTENT(IN) :: nid_start 89 92 CHARACTER(LEN=*),INTENT(IN) :: Field_name 90 93 LOGICAL :: inquire_field … … 106 109 107 110 108 FUNCTION inquire_field_ndims( Field_name)111 FUNCTION inquire_field_ndims(nid_start,Field_name) 109 112 ! give the number of dimensions of "Field_name" stored in the input file 110 113 USE netcdf, only: nf90_inq_varid, nf90_inquire_variable, & … … 112 115 USE mod_phys_lmdz_para, only: is_master, bcast 113 116 IMPLICIT NONE 117 INTEGER,INTENT(IN) :: nid_start 114 118 CHARACTER(LEN=*),INTENT(IN) :: Field_name 115 119 INTEGER :: inquire_field_ndims … … 134 138 135 139 136 FUNCTION inquire_dimension( Field_name)140 FUNCTION inquire_dimension(nid_start,Field_name) 137 141 ! check if a given dimension is present in the input file 138 142 USE netcdf, only: nf90_inq_dimid, NF90_NOERR 139 143 USE mod_phys_lmdz_para, only: is_master, bcast 140 144 IMPLICIT NONE 145 INTEGER,INTENT(IN) :: nid_start 141 146 CHARACTER(LEN=*),INTENT(IN) :: Field_name 142 147 LOGICAL :: inquire_dimension … … 157 162 END FUNCTION inquire_dimension 158 163 159 FUNCTION inquire_dimension_length( Field_name)164 FUNCTION inquire_dimension_length(nid_start,Field_name) 160 165 ! give the length of the "Field_name" dimension stored in the input file 161 166 USE netcdf, only: nf90_inquire_dimension, nf90_inq_dimid, & … … 163 168 USE mod_phys_lmdz_para, only: is_master, bcast 164 169 IMPLICIT NONE 170 INTEGER,INTENT(IN) :: nid_start 165 171 CHARACTER(LEN=*),INTENT(IN) :: Field_name 166 172 INTEGER :: inquire_dimension_length … … 186 192 187 193 188 SUBROUTINE Get_Field_r1( field_name,field,found,timeindex)194 SUBROUTINE Get_Field_r1(nid_start,field_name,field,found,timeindex) 189 195 ! For a surface field 190 196 use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid) 191 197 IMPLICIT NONE 198 INTEGER,INTENT(IN) :: nid_start 192 199 CHARACTER(LEN=*),INTENT(IN) :: Field_name 193 200 REAL,INTENT(INOUT) :: Field(:) … … 205 212 206 213 IF (PRESENT(found)) THEN 207 CALL Get_field_rgen( field_name,field,1,corners,edges,found)214 CALL Get_field_rgen(nid_start,field_name,field,1,corners,edges,found) 208 215 ELSE 209 CALL Get_field_rgen( field_name,field,1,corners,edges)216 CALL Get_field_rgen(nid_start,field_name,field,1,corners,edges) 210 217 ENDIF 211 218 212 219 END SUBROUTINE Get_Field_r1 213 220 214 SUBROUTINE Get_Field_r2( field_name,field,found,timeindex)221 SUBROUTINE Get_Field_r2(nid_start,field_name,field,found,timeindex) 215 222 ! For a "3D" horizontal-vertical field 216 223 use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid) 217 224 IMPLICIT NONE 225 INTEGER,INTENT(IN) :: nid_start 218 226 CHARACTER(LEN=*),INTENT(IN) :: Field_name 219 227 REAL,INTENT(INOUT) :: Field(:,:) … … 232 240 233 241 IF (PRESENT(found)) THEN 234 CALL Get_field_rgen( field_name,field,size(field,2),&242 CALL Get_field_rgen(nid_start,field_name,field,size(field,2),& 235 243 corners,edges,found) 236 244 ELSE 237 CALL Get_field_rgen( field_name,field,size(field,2),&245 CALL Get_field_rgen(nid_start,field_name,field,size(field,2),& 238 246 corners,edges) 239 247 ENDIF … … 242 250 END SUBROUTINE Get_Field_r2 243 251 244 SUBROUTINE Get_Field_r3( field_name,field,found,timeindex)252 SUBROUTINE Get_Field_r3(nid_start,field_name,field,found,timeindex) 245 253 ! for a "4D" field surf/alt/?? 246 254 use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid) 247 255 IMPLICIT NONE 256 INTEGER,INTENT(IN) :: nid_start 248 257 CHARACTER(LEN=*),INTENT(IN) :: Field_name 249 258 REAL,INTENT(INOUT) :: Field(:,:,:) … … 263 272 264 273 IF (PRESENT(found)) THEN 265 CALL Get_field_rgen( field_name,field,size(field,2)*size(field,3),&274 CALL Get_field_rgen(nid_start,field_name,field,size(field,2)*size(field,3),& 266 275 corners,edges,found) 267 276 ELSE 268 CALL Get_field_rgen( field_name,field,size(field,2)*size(field,3),&277 CALL Get_field_rgen(nid_start,field_name,field,size(field,2)*size(field,3),& 269 278 corners,edges) 270 279 ENDIF … … 272 281 END SUBROUTINE Get_Field_r3 273 282 274 SUBROUTINE Get_field_rgen( field_name,field,field_size, &283 SUBROUTINE Get_field_rgen(nid_start,field_name,field,field_size, & 275 284 corners,edges,found) 276 285 USE netcdf … … 279 288 USE mod_phys_lmdz_para 280 289 IMPLICIT NONE 290 INTEGER,INTENT(IN) :: nid_start 281 291 CHARACTER(LEN=*) :: Field_name 282 292 INTEGER :: field_size … … 296 306 297 307 IF (ierr==NF90_NOERR) THEN 298 CALL body(field_glo )308 CALL body(field_glo,nid_start) 299 309 tmp_found=.TRUE. 300 310 ELSE … … 322 332 CONTAINS 323 333 324 SUBROUTINE body(field_glo )334 SUBROUTINE body(field_glo,nid_start) 325 335 REAL :: field_glo(klon_glo*field_size) 336 INTEGER,INTENT(IN) :: nid_start 326 337 ierr=NF90_GET_VAR(nid_start,varid,field_glo,corners,edges) 327 338 IF (ierr/=NF90_NOERR) THEN … … 349 360 350 361 351 SUBROUTINE get_var_r0( var_name,var,found)362 SUBROUTINE get_var_r0(nid_start,var_name,var,found) 352 363 ! Get a scalar from input file 353 364 IMPLICIT NONE 365 INTEGER,INTENT(IN) :: nid_start 354 366 CHARACTER(LEN=*),INTENT(IN) :: var_name 355 367 REAL,INTENT(INOUT) :: var … … 359 371 360 372 IF (PRESENT(found)) THEN 361 CALL Get_var_rgen( var_name,varout,size(varout),found)373 CALL Get_var_rgen(nid_start,var_name,varout,size(varout),found) 362 374 ELSE 363 CALL Get_var_rgen( var_name,varout,size(varout))375 CALL Get_var_rgen(nid_start,var_name,varout,size(varout)) 364 376 ENDIF 365 377 var=varout(1) … … 367 379 END SUBROUTINE get_var_r0 368 380 369 SUBROUTINE get_var_r1( var_name,var,found)381 SUBROUTINE get_var_r1(nid_start,var_name,var,found) 370 382 ! Get a vector from input file 371 383 IMPLICIT NONE … … 373 385 REAL,INTENT(INOUT) :: var(:) 374 386 LOGICAL,OPTIONAL,INTENT(OUT) :: found 387 INTEGER,INTENT(IN) :: nid_start 375 388 376 389 IF (PRESENT(found)) THEN 377 CALL Get_var_rgen( var_name,var,size(var),found)390 CALL Get_var_rgen(nid_start,var_name,var,size(var),found) 378 391 ELSE 379 CALL Get_var_rgen( var_name,var,size(var))392 CALL Get_var_rgen(nid_start,var_name,var,size(var)) 380 393 ENDIF 381 394 382 395 END SUBROUTINE get_var_r1 383 396 384 SUBROUTINE get_var_r2( var_name,var,found)397 SUBROUTINE get_var_r2(nid_start,var_name,var,found) 385 398 ! Get a 2D field from input file 386 399 IMPLICIT NONE … … 388 401 REAL,INTENT(OUT) :: var(:,:) 389 402 LOGICAL,OPTIONAL,INTENT(OUT) :: found 403 INTEGER,INTENT(IN) :: nid_start 390 404 391 405 IF (PRESENT(found)) THEN 392 CALL Get_var_rgen( var_name,var,size(var),found)406 CALL Get_var_rgen(nid_start,var_name,var,size(var),found) 393 407 ELSE 394 CALL Get_var_rgen( var_name,var,size(var))408 CALL Get_var_rgen(nid_start,var_name,var,size(var)) 395 409 ENDIF 396 410 397 411 END SUBROUTINE get_var_r2 398 412 399 SUBROUTINE get_var_r3( var_name,var,found)413 SUBROUTINE get_var_r3(nid_start,var_name,var,found) 400 414 ! Get a 3D field frominput file 401 415 IMPLICIT NONE … … 403 417 REAL,INTENT(INOUT) :: var(:,:,:) 404 418 LOGICAL,OPTIONAL,INTENT(OUT) :: found 419 INTEGER,INTENT(IN) :: nid_start 405 420 406 421 IF (PRESENT(found)) THEN 407 CALL Get_var_rgen( var_name,var,size(var),found)422 CALL Get_var_rgen(nid_start,var_name,var,size(var),found) 408 423 ELSE 409 CALL Get_var_rgen( var_name,var,size(var))424 CALL Get_var_rgen(nid_start,var_name,var,size(var)) 410 425 ENDIF 411 426 412 427 END SUBROUTINE get_var_r3 413 428 414 SUBROUTINE Get_var_rgen( var_name,var,var_size,found)429 SUBROUTINE Get_var_rgen(nid_start,var_name,var,var_size,found) 415 430 USE netcdf 416 431 USE dimphy … … 418 433 USE mod_phys_lmdz_para 419 434 IMPLICIT NONE 435 INTEGER,INTENT(IN) :: nid_start 420 436 CHARACTER(LEN=*) :: var_name 421 437 INTEGER :: var_size … … 463 479 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 464 480 465 SUBROUTINE create_restartphy(filename )481 SUBROUTINE create_restartphy(filename,nid_restart) 466 482 USE netcdf, only: NF90_CREATE, NF90_CLOBBER, NF90_64BIT_OFFSET, & 467 483 NF90_NOERR, nf90_strerror, & … … 478 494 IMPLICIT NONE 479 495 CHARACTER(LEN=*),INTENT(IN) :: filename 496 INTEGER,INTENT(INOUT) :: nid_restart 480 497 INTEGER :: ierr 481 498 … … 580 597 END SUBROUTINE create_restartphy 581 598 582 SUBROUTINE open_restartphy(filename )599 SUBROUTINE open_restartphy(filename,nid_restart) 583 600 USE netcdf, only: NF90_OPEN, NF90_NOERR, NF90_WRITE, nf90_strerror 584 601 USE mod_phys_lmdz_para, only: is_master … … 586 603 IMPLICIT NONE 587 604 CHARACTER(LEN=*),INTENT(IN) :: filename 605 INTEGER,INTENT(INOUT) :: nid_restart 588 606 INTEGER :: ierr 589 607 … … 599 617 END SUBROUTINE open_restartphy 600 618 601 SUBROUTINE close_restartphy 619 SUBROUTINE close_restartphy(nid_restart) 602 620 USE netcdf, only: NF90_CLOSE 603 621 USE mod_phys_lmdz_para, only: is_master 604 622 IMPLICIT NONE 605 INTEGER :: ierr 623 INTEGER,INTENT(IN) :: nid_restart 624 INTEGER :: ierr 606 625 607 626 IF (is_master) THEN … … 611 630 END SUBROUTINE close_restartphy 612 631 613 SUBROUTINE put_field_r1( field_name,title,field,time)632 SUBROUTINE put_field_r1(nid_restart,field_name,title,field,time) 614 633 ! For a surface field 615 634 IMPLICIT NONE 635 INTEGER,INTENT(IN) :: nid_restart 616 636 CHARACTER(LEN=*),INTENT(IN) :: field_name 617 637 CHARACTER(LEN=*),INTENT(IN) :: title … … 621 641 IF (present(time)) THEN 622 642 ! if timeindex is present, it is a time-dependent variable 623 CALL put_field_rgen( field_name,title,field,1,time)643 CALL put_field_rgen(nid_restart,field_name,title,field,1,time) 624 644 ELSE 625 CALL put_field_rgen( field_name,title,field,1)645 CALL put_field_rgen(nid_restart,field_name,title,field,1) 626 646 ENDIF 627 647 628 648 END SUBROUTINE put_field_r1 629 649 630 SUBROUTINE put_field_r2( field_name,title,field,time)650 SUBROUTINE put_field_r2(nid_restart,field_name,title,field,time) 631 651 ! For a "3D" horizontal-vertical field 632 652 IMPLICIT NONE 653 INTEGER,INTENT(IN) :: nid_restart 633 654 CHARACTER(LEN=*),INTENT(IN) :: field_name 634 655 CHARACTER(LEN=*),INTENT(IN) :: title … … 638 659 IF (present(time)) THEN 639 660 ! if timeindex is present, it is a time-dependent variable 640 CALL put_field_rgen( field_name,title,field,size(field,2),time)661 CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2),time) 641 662 ELSE 642 CALL put_field_rgen( field_name,title,field,size(field,2))663 CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2)) 643 664 ENDIF 644 665 645 666 END SUBROUTINE put_field_r2 646 667 647 SUBROUTINE put_field_r3( field_name,title,field,time)668 SUBROUTINE put_field_r3(nid_restart,field_name,title,field,time) 648 669 ! For a "4D" field surf/alt/?? 649 670 IMPLICIT NONE 671 INTEGER,INTENT(IN) :: nid_restart 650 672 CHARACTER(LEN=*),INTENT(IN) :: field_name 651 673 CHARACTER(LEN=*),INTENT(IN) :: title … … 655 677 IF (present(time)) THEN 656 678 ! if timeindex is present, it is a time-dependent variable 657 CALL put_field_rgen( field_name,title,field,size(field,2)*size(field,3),&679 CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2)*size(field,3),& 658 680 time) 659 681 ELSE 660 CALL put_field_rgen( field_name,title,field,size(field,2)*size(field,3))682 CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2)*size(field,3)) 661 683 ENDIF 662 684 663 685 END SUBROUTINE put_field_r3 664 686 665 SUBROUTINE put_field_rgen( field_name,title,field,field_size,time)687 SUBROUTINE put_field_rgen(nid_restart,field_name,title,field,field_size,time) 666 688 USE netcdf 667 689 USE dimphy … … 673 695 674 696 IMPLICIT NONE 697 INTEGER,INTENT(IN) :: nid_restart 675 698 CHARACTER(LEN=*),INTENT(IN) :: field_name 676 699 CHARACTER(LEN=*),INTENT(IN) :: title … … 918 941 END SUBROUTINE put_field_rgen 919 942 920 SUBROUTINE put_var_r0( var_name,title,var)943 SUBROUTINE put_var_r0(nid_restart,var_name,title,var) 921 944 ! Put a scalar in file 922 945 IMPLICIT NONE 946 INTEGER,INTENT(IN) :: nid_restart 923 947 CHARACTER(LEN=*),INTENT(IN) :: var_name 924 948 CHARACTER(LEN=*),INTENT(IN) :: title … … 928 952 varin(1)=var 929 953 930 CALL put_var_rgen( var_name,title,varin,size(varin))954 CALL put_var_rgen(nid_restart,var_name,title,varin,size(varin)) 931 955 932 956 END SUBROUTINE put_var_r0 933 957 934 958 935 SUBROUTINE put_var_r1( var_name,title,var)959 SUBROUTINE put_var_r1(nid_restart,var_name,title,var) 936 960 ! Put a vector in file 937 961 IMPLICIT NONE 962 INTEGER,INTENT(IN) :: nid_restart 938 963 CHARACTER(LEN=*),INTENT(IN) :: var_name 939 964 CHARACTER(LEN=*),INTENT(IN) :: title 940 965 REAL,INTENT(IN) :: var(:) 941 966 942 CALL put_var_rgen( var_name,title,var,size(var))967 CALL put_var_rgen(nid_restart,var_name,title,var,size(var)) 943 968 944 969 END SUBROUTINE put_var_r1 945 970 946 SUBROUTINE put_var_r2( var_name,title,var)971 SUBROUTINE put_var_r2(nid_restart,var_name,title,var) 947 972 ! Put a 2D field in file 948 973 IMPLICIT NONE 974 INTEGER,INTENT(IN) :: nid_restart 949 975 CHARACTER(LEN=*),INTENT(IN) :: var_name 950 976 CHARACTER(LEN=*),INTENT(IN) :: title 951 977 REAL,INTENT(IN) :: var(:,:) 952 978 953 CALL put_var_rgen( var_name,title,var,size(var))979 CALL put_var_rgen(nid_restart,var_name,title,var,size(var)) 954 980 955 981 END SUBROUTINE put_var_r2 956 982 957 SUBROUTINE put_var_r3( var_name,title,var)983 SUBROUTINE put_var_r3(nid_restart,var_name,title,var) 958 984 ! Put a 3D field in file 959 985 IMPLICIT NONE 986 INTEGER,INTENT(IN) :: nid_restart 960 987 CHARACTER(LEN=*),INTENT(IN) :: var_name 961 988 CHARACTER(LEN=*),INTENT(IN) :: title 962 989 REAL,INTENT(IN) :: var(:,:,:) 963 990 964 CALL put_var_rgen( var_name,title,var,size(var))991 CALL put_var_rgen(nid_restart,var_name,title,var,size(var)) 965 992 966 993 END SUBROUTINE put_var_r3 967 994 968 SUBROUTINE put_var_rgen( var_name,title,var,var_size)995 SUBROUTINE put_var_rgen(nid_restart,var_name,title,var,var_size) 969 996 USE netcdf, only: NF90_REDEF, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_VAR, & 970 997 NF90_FLOAT, NF90_DOUBLE, & … … 976 1003 USE ocean_slab_mod, ONLY: nslay 977 1004 IMPLICIT NONE 1005 INTEGER,INTENT(IN) :: nid_restart 978 1006 CHARACTER(LEN=*),INTENT(IN) :: var_name 979 1007 CHARACTER(LEN=*),INTENT(IN) :: title … … 1059 1087 END SUBROUTINE put_var_rgen 1060 1088 1061 SUBROUTINE put_var_c1( var_name,title,var)1089 SUBROUTINE put_var_c1(nid_restart,var_name,title,var) 1062 1090 ! Put a vector of characters in file 1063 1091 … … 1069 1097 1070 1098 IMPLICIT NONE 1099 INTEGER,INTENT(IN) :: nid_restart 1071 1100 CHARACTER(LEN=*),INTENT(IN) :: var_name 1072 1101 CHARACTER(LEN=*),INTENT(IN) :: title
Note: See TracChangeset
for help on using the changeset viewer.